File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -542,7 +542,13 @@ std::size_t winrt_ssocket_service_base::do_receive(
542542 bufs.buffers ()[0 ], bufs.buffers ()[0 ]->Capacity ,
543543 Windows::Storage::Streams::InputStreamOptions::Partial), ec);
544544
545- return bufs.buffers ()[0 ]->Length ;
545+ std::size_t bytes_transferred = bufs.buffers ()[0 ]->Length ;
546+ if (bytes_transferred == 0 && !ec)
547+ {
548+ ec = asio::error::eof;
549+ }
550+
551+ return bytes_transferred;
546552 }
547553 catch (Platform::Exception^ e)
548554 {
Original file line number Diff line number Diff line change @@ -66,7 +66,13 @@ class winrt_socket_recv_op :
6666 }
6767#endif // defined(ASIO_ENABLE_BUFFER_DEBUGGING)
6868
69- // TODO check for end-of-file.
69+ std::size_t bytes_transferred = o->result_ ? o->result_ ->Length : 0 ;
70+ if (bytes_transferred == 0 && !o->ec_ &&
71+ !buffer_sequence_adapter<asio::mutable_buffer,
72+ MutableBufferSequence>::all_empty (o->buffers_ ))
73+ {
74+ o->ec_ = asio::error::eof;
75+ }
7076
7177 // Make a copy of the handler so that the memory can be deallocated before
7278 // the upcall is made. Even if we're not about to make an upcall, a
@@ -75,7 +81,7 @@ class winrt_socket_recv_op :
7581 // to ensure that any owning sub-object remains valid until after we have
7682 // deallocated the memory here.
7783 detail::binder2<Handler, asio::error_code, std::size_t >
78- handler (o->handler_ , o->ec_ , o-> result_ ? o-> result_ -> Length : 0 );
84+ handler (o->handler_ , o->ec_ , bytes_transferred );
7985 p.h = asio::detail::addressof (handler.handler_ );
8086 p.reset ();
8187
You can’t perform that action at this time.
0 commit comments