Closing the socket is not a problem, but the socket is destroyed and freed. One way to deal with it is to simply make sure that the socket survives the io_service where the work is done. In other words, you just remember to remove it until io_service comes out. Obviously, this will not work in any situation.
, , io_service, ASIO , . shared_ptr, , io_service.
, , .