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