
"Nicola Michael Gutberlet"
At first: Thanks to all the fast responses - this mailing list seems to work properly ;-)
Scott Gifford:
[...] or else use TCP keepalives.
Can you shortly explain how to use "keepalives" and how they work / react in case of a closed other side?
See this example: http://www.boost.org/doc/libs/1_41_0/doc/html/boost_asio/reference/socket_ba... Basically, with this option set your TCP implementation will periodically send a packet that effectively has zero length but requires acknowledgement from the other side, triggering the timeout counter to start. How frequently keepalive packets are sent is determined by your TCP implementation, and is typically set on a system-wide basis and defaults to about an hour. The effect of this is the same as you writing to the stream periodically, except that the other side doesn't see any writes at the application layer. That is, you still have to read from the socket to detect an error. If the application protocol you are using on top of TCP supports it, sending some kind of no-op command periodically will give you a bit more control over timing. Hope this helps! ----Scott.