title: How to check if SSL socket gets closed (async)
body: <p>I've been using boost asio for networking for some time, but never for SSL sockets. Now i'm required to use SSL sockets and they work pretty fine. But i am not able to find out when a sockets get closed (I usually did this as I did with regular sockets - checking the error value when using <code>boost::asio::async_read_until()</code> in the callback function.</p>
  
  <p>Here's some relevant code snippets:</p>
  
  <pre><code>boost::asio::streambuf streambuf;
  boost::asio::ssl::context sslctx(io_service, boost::asio::ssl::context::tlsv1);
  boost::asio::ssl::stream&lt;boost::asio::ip::tcp::socket&gt; sock(io_service, sslctx);
  
  void DoAsyncRead()
  {
      boost::asio::async_read_until(sock, streambuf, "\n", MyReadHandler);
  }
  
  void MyReadHandler(const boost::system::error_code&amp; error, size_t bytes_transferred)
  {
    if (error) {
      std::cout &lt;&lt; "Read error: " &lt;&lt; error.message() &lt;&lt; std::endl;
    } else {
      // ...
    }
  }
  </code></pre>
  
  <p>The error condition is never true, even if I kill the server, or drop the client connection. How can I track if the connection is closed?</p>