title: is it safe to to destroy a socket object while an asyn_read might be going on in boost.ASIO?
body: <p>In the following code:</p>
  
  <pre><code>tcp::socket socket(io_service);
  tcp::endpoint ep(boost::asio::ip::address::from_string(addr), i);
  
  
  socket.async_connect(ep, &amp;connect_handler);
  
  socket.close();
  </code></pre>
  
  <p>is it correct to close the socket object, or should I close it only in the <code>connect_handler()</code>,  resort to shared_ptr to prolong the life of of the socket object?
  Thanks.</p>