Boost C++ Libraries: Ticket #12545: stream_socket_service forcibly takes responsibility for closing the native_handle https://svn.boost.org/trac10/ticket/12545 <p> When using the <code>basic_stream_socket</code> <a class="ext-link" href="https://github.com/boostorg/asio/blob/36eef63a9cf8ae609716d76ccb3906ff9769d53a/include/boost/asio/basic_stream_socket.hpp#L130"><span class="icon">​</span>constructor with a native_handle_type</a>, it seems that the service will call <code>close()</code> on it <a class="ext-link" href="https://github.com/boostorg/asio/blob/36eef63a9cf8ae609716d76ccb3906ff9769d53a/include/boost/asio/detail/impl/reactive_socket_service_base.ipp#L91"><span class="icon">​</span>upon destruction</a>. </p> <p> I have no expectation on this behavior, but this should be stressed in the documentation. Using this constructor (or the <code>assign()</code> method) is very handy when dealing with third-parties, but those very same third-parties can have the same policy of auto-closing. </p> <p> This will lead to double closing, which is the best way for data corruption in a process that constantly opens and closes files. </p> <p> I will go for a call to <code>dup()</code> before using the <code>ip::tcp::socket</code> for now. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12545 Trac 1.4.3