Boost logo

Boost Users :

Subject: Re: [Boost-users] Why cannot asio tcp socket server detect TCP disconnection when the client device lost power?
From: Andreas Wehrmann (a.wehrmann_at_[hidden])
Date: 2017-06-29 05:09:57


On 06/29/2017 06:28 AM, jupiter via Boost-users wrote:
> Hi,
>
> The asio tcp server can detect the disconnection when the client program
> stop. But I have small device when it lost power, the server won't be able
> to detect the TCP disconnection. Does the boost socket has TCP timeout?
> What is an effective way to handle this situation other than running
> heartbeat in user level?
>
> Thank you.
>
> Kind regards,
>
> - j
>

Well, you could always activate TCP keepalive via socket options
and set the corresponding timeout and interval values accordingly.

However, it depends on what you want to do really:
The TCP keepalive mechanism is something that is implemented by the TCP
stack of the operating system
and will only check whether the connection is still alive, but that may
not be enough because
it won't check whether the service you're connected to is actually
working/responding.
And this is where the application layer heartbeat comes back in.

Hope this gives you some idea.

Regards,
Andreas


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