Skip to main content

AsSocketState

Trait AsSocketState 

pub trait AsSocketState: AsFd {
    // Provided methods
    unsafe fn wsa_accept_ex(
        &self,
        accept_socket: usize,
        output_buffer: *mut c_void,
        receive_data_length: u32,
        local_address_length: u32,
        remote_address_length: u32,
        bytes_received: *mut u32,
        overlapped: *mut OVERLAPPED,
    ) -> Poll<Result<usize, Error>> { ... }
    unsafe fn wsa_get_accept_ex_sockaddrs(
        &self,
        output_buffer: *const c_void,
        receive_data_length: u32,
        local_address_length: u32,
        remote_address_length: u32,
        local_sockaddr: *mut *mut SOCKADDR,
        local_sockaddr_length: *mut i32,
        remote_sockaddr: *mut *mut SOCKADDR,
        remote_sockaddr_length: *mut i32,
    ) -> Result<(), Error> { ... }
    unsafe fn wsa_connect_ex(
        &self,
        name: *const SOCKADDR,
        name_length: i32,
        send_buffer: *const c_void,
        send_data_length: u32,
        bytes_sent: *mut u32,
        overlapped: *mut OVERLAPPED,
    ) -> Poll<Result<usize, Error>> { ... }
    unsafe fn wsa_disconnect_ex(
        &self,
        overlapped: *mut OVERLAPPED,
        flags: u32,
        reserved: u32,
    ) -> Poll<Result<usize, Error>> { ... }
    unsafe fn wsa_recv_msg(
        &self,
        msg: *mut WSAMSG,
        bytes_received: *mut u32,
        overlapped: *mut OVERLAPPED,
        completion_routine: Option<unsafe extern "system" fn(u32, u32, *mut OVERLAPPED, u32)>,
    ) -> Poll<Result<usize, Error>> { ... }
}
Expand description

Per-socket state needed by the asynchronous operations.

The winsock extensions (AcceptEx, ConnectEx, …) are resolved per socket: the pointers returned by SIO_GET_EXTENSION_FUNCTION_POINTER belong to the provider serving that socket, and sharing them with another socket crashes when a layered service provider is installed.

Provided Methods§

unsafe fn wsa_accept_ex( &self, accept_socket: usize, output_buffer: *mut c_void, receive_data_length: u32, local_address_length: u32, remote_address_length: u32, bytes_received: *mut u32, overlapped: *mut OVERLAPPED, ) -> Poll<Result<usize, Error>>

AcceptEx.

§Safety

output_buffer must be large enough for both addresses, bytes_received must be valid for writes, and overlapped must outlive the operation.

unsafe fn wsa_get_accept_ex_sockaddrs( &self, output_buffer: *const c_void, receive_data_length: u32, local_address_length: u32, remote_address_length: u32, local_sockaddr: *mut *mut SOCKADDR, local_sockaddr_length: *mut i32, remote_sockaddr: *mut *mut SOCKADDR, remote_sockaddr_length: *mut i32, ) -> Result<(), Error>

GetAcceptExSockaddrs.

§Safety

output_buffer must hold the addresses written by AsSocketState::wsa_accept_ex, and the output pointers must be valid for writes.

unsafe fn wsa_connect_ex( &self, name: *const SOCKADDR, name_length: i32, send_buffer: *const c_void, send_data_length: u32, bytes_sent: *mut u32, overlapped: *mut OVERLAPPED, ) -> Poll<Result<usize, Error>>

ConnectEx.

§Safety

name must be valid for name_length bytes, bytes_sent must be valid for writes, and overlapped must outlive the operation.

unsafe fn wsa_disconnect_ex( &self, overlapped: *mut OVERLAPPED, flags: u32, reserved: u32, ) -> Poll<Result<usize, Error>>

DisconnectEx.

§Safety

overlapped must outlive the operation.

unsafe fn wsa_recv_msg( &self, msg: *mut WSAMSG, bytes_received: *mut u32, overlapped: *mut OVERLAPPED, completion_routine: Option<unsafe extern "system" fn(u32, u32, *mut OVERLAPPED, u32)>, ) -> Poll<Result<usize, Error>>

WSARecvMsg.

§Safety

msg must describe buffers that outlive the operation, bytes_received must be valid for writes, and overlapped must outlive it too.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§