Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Detecting a closed socket

by kschwab (Priest)
on Aug 05, 2003 at 14:06 UTC ( #280982=note: print w/ replies, xml ) Need Help??


in reply to Detecting a closed socket

Using sysread(), your indication that the other end has closed the connection would be a "successful sysread of zero bytes". This works when the other end does an orderly close() or shutdown() of the send side of the socket. So, you would have to test the return value of sysread() for undef (error) and zero( end of file, a.k.a, client closed connection ).

In the event that something unusual happens ( perhaps the client crashed ?), keepalives could be helpful. ($sockobj->sockopt(SO_KEEPALIVE,1);)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://280982]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2016-07-28 00:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What is your favorite alternate name for a (specific) keyboard key?


















    Results (251 votes). Check out past polls.