Boost C++ Libraries: Ticket #12528: boost::asio::ssl_stream "short read error" when a connection is closed https://svn.boost.org/trac10/ticket/12528 <p> I use boost::asio to make client/server programs using SSL and I use boost::asio example as a reference. The problem is that when client or server closes the connection, the other side has "short read error". Using NOT SSL, this problem isn't detected, this is the problem using SSL. When the client program closes connection, the server has "short read error". The other way, the server program closes connection, the client has "short read error" too. The original sample programs don't output errors, so I add the codes which output errors. </p> <p> <a href="http://www.boost.org/doc/libs/1_62_0/doc/html/boost_asio/example/cpp03/ssl/server.cpp">http://www.boost.org/doc/libs/1_62_0/doc/html/boost_asio/example/cpp03/ssl/server.cpp</a> <a href="http://www.boost.org/doc/libs/1_62_0/doc/html/boost_asio/example/cpp03/ssl/client.cpp">http://www.boost.org/doc/libs/1_62_0/doc/html/boost_asio/example/cpp03/ssl/client.cpp</a> </p> <p> [server.cpp] </p> <pre class="wiki">void handle_read(const boost::system::error_code&amp; error, size_t bytes_transferred) { if (!error) { boost::asio::async_write(socket_, boost::asio::buffer(data_, bytes_transferred), boost::bind(&amp;session::handle_write, this, boost::asio::placeholders::error)); } else { std::cout &lt;&lt; "Server Error: " &lt;&lt; error.message() &lt;&lt; "\n"; //add delete this; } } void handle_write(const boost::system::error_code&amp; error) { if (!error) { socket_.async_read_some(boost::asio::buffer(data_, max_length), boost::bind(&amp;session::handle_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); } else { std::cout &lt;&lt; "Server Error: " &lt;&lt; error.message() &lt;&lt; "\n"; //add delete this; } } </pre><p> The sample programs don't use "socket_.shutdown()" and "socket_.lowest_layer().close()". The shutting down process is automatically executed by the destructor. I use "socket_.shutdown()" and "socket_.lowest_layer().close()" using the following page as a reference, but the same error happens. <a class="ext-link" href="http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error"><span class="icon">​</span>http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error</a> </p> <p> Other hand, the release note of Boost_1.58.0 has the Updated Libraries log which is "Fixed an ssl::stream&lt;&gt; bug that may result in spurious 'short read' errors". I can't figure out this change has relations about this problem, but this event is already detected. <a href="http://www.boost.org/users/history/version_1_58_0.html">http://www.boost.org/users/history/version_1_58_0.html</a> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12528 Trac 1.4.3