Hello guys,
I seem to be stuck with this one. Need your expert input on this.
I used a IO::Socket::INET object to connect to a whois server (port 43, and no I'm not trying to parse emails to spam!). I send the domain name and read back the whois information. Information is returned as a series of strings. Half the time everything is ok. Sometimes the reading is 'stuck'; the object cannot return the next string, causing the whole program to hang. Below is the code snippet:
my $socket = IO::Socket::INET->new(
PeerAddr=>$WHOISServer,
PeerPort=>'43',
Proto=>'tcp',
Timeout=>5,
Type=>SOCK_STREAM,
);
return undef if (!$socket);
while (my $line = <$socket>)
{
print "=>$line";
}I did a Telnet, and I get the same experience. Sometimes the first few lines will come out, then the screen freezes. The only difference is that if I press the Enter key a few times Telnet will move on and disconnect. I interprete this as perhaps the buffer needs to be flushed. Unfortunately, according to the documentation autoflush is on by default. So I am at my wit's end.
I need a way to make sure my program does not hang here. Is there any way I can timeout the reading (notice my Timeout setting in the code. Did not work when reading)?
Please advise.
_______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
