Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost::asio - how to detect if a remote socketsclient has disconnected
From: Etienne Philip Pretorius (icewolfhunter_at_[hidden])
Date: 2009-07-27 13:58:45


Jonathan Franklin wrote:
> On Mon, Jul 27, 2009 at 10:17 AM, Etienne Philip
> Pretorius<icewolfhunter_at_[hidden]> wrote:
>
>> SO_KEEPALIVE?
>>
>
> SO_KEEPALIVE just tries to prevent one end from closing a connection
> that has been idle for too long under "normal" operation.
>
> The problem we're trying to detect is when the other side of the
> connection drops off silently so we don't waste time *writing* data to
> the connection. This is an error condition, SO_KEEPALIVE won't help
> AFAICT.
>
>
Then the others have answered the question. Whether you use
async/blocking/non-blocking (dispatch method) you will only get an error
if the underlying Network OS thinks that there is an error. In TCP,
there should be a FIN state that the Network OS should pick up as the
close call on the socket. Anyway - there is no 100% way to establish
that this was because the client disconnected or the link between the
two went down.

There is a possibility that a shutdown on the read side from the server
could cause the Network OS to detect if there is no ACK from the client
when the half close is called. Also at that stage if the shutdown was
ACK'ed you will get a read call with NO ERROR and 0 bytes read.

> Jon
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net