pub struct BlockingSocket { /* private fields */ }Expand description
A connected overlapped socket that completes operations synchronously, one at a time, via a Winsock completion event.
This is the socket counterpart of the handle blocking backend. It cannot use
GetOverlappedResult on the socket handle, so each call creates a
WSACreateEvent, issues the operation with that event in OVERLAPPED.hEvent,
and blocks on WSAGetOverlappedResult.
Implementations§
Source§impl BlockingSocket
impl BlockingSocket
Sourcepub fn new(socket: OwnedSocket) -> Self
pub fn new(socket: OwnedSocket) -> Self
Take ownership of a connected overlapped socket for synchronous completion.
Sourcepub fn socket(&self) -> BorrowedSocket<'_>
pub fn socket(&self) -> BorrowedSocket<'_>
Borrow the underlying socket.
Sourcepub fn recv(&self, buffer: &mut [u8]) -> Result<usize>
pub fn recv(&self, buffer: &mut [u8]) -> Result<usize>
Receive into buffer, blocking until the receive completes, and return
the number of bytes received.
Takes a plain &mut [u8] and allocates nothing, matching
BlockingSocket::send: this call does not return until the operation
is over, so an ordinary borrow provably covers it.
§Errors
Returns io::ErrorKind::InvalidInput if buffer is longer than
u32::MAX, which WSABUF’s byte count cannot express, or any error from
issuing or completing the receive.