Implement end-of-file condition for WinRT stream sockets.
This commit is contained in:
parent
e51d790cad
commit
383b05ecc5
@ -542,7 +542,13 @@ std::size_t winrt_ssocket_service_base::do_receive(
|
||||
bufs.buffers()[0], bufs.buffers()[0]->Capacity,
|
||||
Windows::Storage::Streams::InputStreamOptions::Partial), ec);
|
||||
|
||||
return bufs.buffers()[0]->Length;
|
||||
std::size_t bytes_transferred = bufs.buffers()[0]->Length;
|
||||
if (bytes_transferred == 0 && !ec)
|
||||
{
|
||||
ec = asio::error::eof;
|
||||
}
|
||||
|
||||
return bytes_transferred;
|
||||
}
|
||||
catch (Platform::Exception^ e)
|
||||
{
|
||||
|
@ -66,7 +66,13 @@ public:
|
||||
}
|
||||
#endif // defined(ASIO_ENABLE_BUFFER_DEBUGGING)
|
||||
|
||||
// TODO check for end-of-file.
|
||||
std::size_t bytes_transferred = o->result_ ? o->result_->Length : 0;
|
||||
if (bytes_transferred == 0 && !o->ec_ &&
|
||||
!buffer_sequence_adapter<asio::mutable_buffer,
|
||||
MutableBufferSequence>::all_empty(o->buffers_))
|
||||
{
|
||||
o->ec_ = asio::error::eof;
|
||||
}
|
||||
|
||||
// Make a copy of the handler so that the memory can be deallocated before
|
||||
// the upcall is made. Even if we're not about to make an upcall, a
|
||||
@ -75,7 +81,7 @@ public:
|
||||
// to ensure that any owning sub-object remains valid until after we have
|
||||
// deallocated the memory here.
|
||||
detail::binder2<Handler, asio::error_code, std::size_t>
|
||||
handler(o->handler_, o->ec_, o->result_ ? o->result_->Length : 0);
|
||||
handler(o->handler_, o->ec_, bytes_transferred);
|
||||
p.h = asio::detail::addressof(handler.handler_);
|
||||
p.reset();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user