Boost logo

Boost Users :

Subject: Re: [Boost-users] Why cannot asio tcp socket server detect TCP disconnection when the client device lost power?
From: niXman (i.nixman_at_[hidden])
Date: 2017-06-29 12:51:07

jupiter via Boost-users 2017-06-29 15:41:


> I have a connection map in my server as part of monitoring system to
> trace
> down the client connections. If the server can be notified by kernel
> for a
> client falling off, that will be
> good to use a callback errorHandler to clean up the socket connection
> as
> well as the connection map automatically.

You should inherit the enable_shared_from_this<your session class>, and
in async ops in your session class you should use shared_from_this()
when start async ops.

For monitoring your session you should use map/any_container with
weak_ptrs, not shared_ptrs.

Regards, niXman
Dual-target(32 & 64-bit) MinGW-W64 compilers for 32 and 64-bit Windows:

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