Hi,
I have problem with Boost/asio – sometimes server returns „short read” error.
I’m using client/server from the examples.
Please write me – is it a bug or just wrong implemented example because the error occurs not every time.
How to protect my application against the error?
Best regards,
Marcin Głogowski
What boost/asio version do you use? What's your platform? What
specific example are you talking about?
_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Windows 7 64 bit ultimate, boost 1.49, examples from:
http://www.stderr.org/doc/libasio-doc/examples/ssl_client_cpp.html
http://www.stderr.org/doc/libasio-doc/examples/ssl_server_cpp.html
Currently SSL works great, but several days ago I had many times “short read” error.
Best regards
Marcin
> What boost/asio version do you use? What's your platform? What
> specific example are you talking about?
>> I have problem with Boost/asio – sometimes server returns „short read”
>> error.
>> I’m using client/server from the examples.
>> Please write me – is it a bug or just wrong implemented example because the
>> error occurs not every time.
>> How to protect my application against the error?
Ok, I see.
On "short read" you should re-start your async.operation (I believe
then you'll get eof).
Actually, after taking a look at the asio sources, I'm a bit confused:
const boost::system::error_code&
engine::map_error_code(boost::system::error_code& ec) const
{
// We only want to map the error::eof code.
if (ec != boost::asio::error::eof)
return ec;
// If there's data yet to be read, it's an error.
if (BIO_wpending(ext_bio_))
{
ec = boost::system::error_code(
ERR_PACK(ERR_LIB_SSL, 0, SSL_R_SHORT_READ),
boost::asio::error::get_ssl_category());
return ec;
}
// SSL v2 doesn't provide a protocol-level shutdown, so an eof on the
// underlying transport is passed through.
if (ssl_ && ssl_->version == SSL2_VERSION)
return ec;
// Otherwise, the peer should have negotiated a proper shutdown.
if ((::SSL_get_shutdown(ssl_) & SSL_RECEIVED_SHUTDOWN) == 0)
{
ec = boost::system::error_code(
ERR_PACK(ERR_LIB_SSL, 0, SSL_R_SHORT_READ),
boost::asio::error::get_ssl_category());
}
return ec;
}
So, in the both cases you get the same error_code (short read). If
"the peer negotiated a proper shutdown", and you try to read more,
wouldn't you get another "short read" - that's the question... I
believe you should experiment and see what you get.