No such thing as a small change | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
In general the way to detect a closed socket is: upon write - handle the SIGPIPE signal. Upon read, use a time out. This doesn't appear to be what the OP is describing.
Basically, if you are a "writer", you can tell very quickly that the pipe is not open anymore for write (although there may still potentially be stuff in it that hasn't been read yet). However if you are "reader", you can't tell the difference between "my partner is really slow" and "he isn't there anymore". You have to conclude that "he isn't there anymore" when he is really, really slow. It is possible to still be reading even after your partner has long since died, and the socket is closed as far as he is concerned. If I am controlling the protocol at both ends, and it is possible for me to do so, I will send an "in-band" signal (Maybe a CTL-D or whatever) to the client to let him know that "I'm done and signing off". This is done to circumvent the client time-out. An "in-band" signal is part of the data stream which the client has to parse. An "out-of-band" signal, like a SIGPIPE signal (for the writer) is not transferred via the data communication stream. There simply is not an out-of-band signal to notify the receiver that the transmitter has "gone off the air". "The BBC concludes our nightly broadcast" is the way that it is done - that is an example of an "in-band" signal. In reply to Re^2: How to monitor TCP Resets using Sockets
by Marshall
|
|