go ahead... be a heretic | |
PerlMonks |
Re: $Socket->connected Not Returning False?by pg (Canon) |
on Oct 21, 2003 at 04:29 UTC ( [id://300826]=note: print w/replies, xml ) | Need Help?? |
connected can not be used to check the actual state of the connection, instead it tells you whether the socket is locally closed. What you can do is to use IO::Select, call can_read first, if can_read says yes, but when you read, you got undef back, then the connection is actually closed. This solution resolves the confusion you mentioned, that you could not differentiate whether the socket is closed or just got an empty string on a open socket. The following code demos this (tested under win98 with AS 5.8.0 build 802):
In Section
Seekers of Perl Wisdom
|
|