I am facing the following issue. I am trying to use a third party library with boost Asio and I need to inject some of the socket descriptors used by the library in io_service event loop.
The approach I use is creating a boost::asio::ip::tcp::socket passing the native handler my library provides.
Problem is that library would just communicate it is not interested in a particular socket notifications (which means that library may close the socket or reuse it at a later point). In any case, I would like to do a clean up of boost sockets and destroy them, but without closing the native handler (i.e. file descriptor).
In short, is there any way of destroying a boost::asio::ip::tcp::socket without closing the underlying handler? I am aware of using posix::stream_descriptor instead, but I would like my solution to be portable.
socket.assign(protocol, native)
has a pre-condition thatsocket
is not open (see the SocketService). If this precondition is not met, then the state ofsocket
remains unchanged. – Tanner Sansbury