Skip to main content

BlockingSocket

Struct BlockingSocket 

Source
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

Source

pub fn new(socket: OwnedSocket) -> Self

Take ownership of a connected overlapped socket for synchronous completion.

Source

pub fn socket(&self) -> BorrowedSocket<'_>

Borrow the underlying socket.

Source

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.

Source

pub fn send(&self, data: &[u8]) -> Result<usize>

Send data, blocking until the send completes, and return the bytes sent.

§Errors

Returns io::ErrorKind::InvalidInput if data is longer than u32::MAX, which WSABUF’s byte count cannot express, or any error from issuing or completing the send.

Trait Implementations§

Source§

impl Debug for BlockingSocket

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.