Hi guys,
I have a socket set up with IO::Socket::INET. It works in that I am able to write to the socket, however I can't capture what the remote host sends back.
I know the connection works, because I can use telnet to drive the dialogue manually and when I send the 'status' request, I get a dump of data back. How can I get my socket to capture this so that I can do something useful with it?
Here's a snip of the code I'm using:
Code:
my $sock = new IO::Socket::INET (
PeerAddr => "$hostname",
PeerPort => "$port",
Blocking => 0,
Proto => 'tcp',
);
print $sock "Action: Login\r\n";
print $sock "UserName: $foo\r\n";
print $sock "Secret: $bar\r\n\r\n";
print $sock "Action: status\r\n\r\n";
$/="\r\n";
open(FH,">>/home/chris/statusdump.txt");
while(my $data=<$sock>){
$data =~ /[a-z]/ || next;
print FH $data;
}
close FH;
cheers
christo