|laziness, impatience, and hubris|
Detecting a closed socketby Flame (Deacon)
|on Aug 05, 2003 at 04:03 UTC||Need Help??|
Flame has asked for the
wisdom of the Perl Monks concerning the following question:
Having failed to locate anything useful via search, chatterbox or the IO::Select, IO::Socket, IO::Socket::INET and Socket docs, I'm forced to waste a SOPW question on it. What is the best/easiest way to detect when the other side of a socket has closed?
Some background: I'm writing a Perl server to work with Java client(s) using IO::Select and IO::Socket::INET. I read from the socket using sysread. I know that IO::Select concludes that a closed socket is constantly waiting to be read from... how I ran into that information I no longer recall, however I'm not entirely certain how to tell if it's closed or not.
I have tried $handle->connected as described in IO::Socket, however, it never seems to return false.
I realize I could have written this a little more clearly, but I'm afraid this will have to do... Thank you for reading, even if you don't know the answer. This is my first foray into networking and communications aside from writing CGI/mod_perl scripts (and we all know those don't really qualify) so any generic tips would be appreciated... In fact, while you're here, anyone know how latency/LAG would affect these kinds of things? (Ie: would sysread give up if lag held up part of a message?)
My code doesn't have bugs, it just develops random features.