From fe13a85c0f01f8be39a069a51488283bbc76010e Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 6 Jan 2015 19:05:48 -0500 Subject: [PATCH] read all available data from closed stream --- Streaming.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Streaming.h b/Streaming.h index 69ef124d..944e40de 100644 --- a/Streaming.h +++ b/Streaming.h @@ -224,9 +224,19 @@ namespace stream // no error handler (boost::system::error_code (), received); else - // socket closed - handler (m_IsReset ? boost::asio::error::make_error_code (boost::asio::error::connection_reset) : - boost::asio::error::make_error_code (boost::asio::error::operation_aborted), received); + { + // stream closed + if (m_IsReset) + { + // stream closed by peer + handler (received > 0 ? boost::system::error_code () : // we still have some data + boost::asio::error::make_error_code (boost::asio::error::connection_reset), // no more data + received); + + } + else // stream closed by us + handler (boost::asio::error::make_error_code (boost::asio::error::operation_aborted), received); + } } else // timeout expired