Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio] Socket closed notification?
From: Scott Gifford (sgifford_at_[hidden])
Date: 2009-12-15 11:00:04

"Nicola Michael Gutberlet" <nicola.gutberlet_at_[hidden]> writes:

> 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:

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!


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at