[][src]Trait miow::net::TcpListenerExt

pub trait TcpListenerExt {
    unsafe fn accept_overlapped(
        &self,
        socket: &TcpStream,
        addrs: &mut AcceptAddrsBuf,
        overlapped: *mut OVERLAPPED
    ) -> Result<bool>;
fn accept_complete(&self, socket: &TcpStream) -> Result<()>;
unsafe fn result(&self, overlapped: *mut OVERLAPPED) -> Result<(usize, u32)>; }

Additional methods for the TcpListener type in the standard library.

Required methods

unsafe fn accept_overlapped(
    &self,
    socket: &TcpStream,
    addrs: &mut AcceptAddrsBuf,
    overlapped: *mut OVERLAPPED
) -> Result<bool>

Perform an accept operation on this listener, accepting a connection in an overlapped fashion.

This function will issue an I/O request to accept an incoming connection with the specified overlapped instance. The socket provided must be a configured but not bound or connected socket, and if successful this will consume the internal socket of the builder to return a TCP stream.

The addrs buffer provided will be filled in with the local and remote addresses of the connection upon completion.

If the accept succeeds immediately, Ok(true) is returned. If the connect indicates that the I/O is currently pending, Ok(false) is returned. Otherwise, the error associated with the operation is returned and no overlapped operation is enqueued.

Unsafety

This function is unsafe because the kernel requires that the addrs and overlapped pointers are valid until the end of the I/O operation. The kernel also requires that overlapped is unique for this I/O operation and is not in use for any other I/O.

To safely use this function callers must ensure that the pointers are valid until the I/O operation is completed, typically via completion ports and waiting to receive the completion notification on the port.

fn accept_complete(&self, socket: &TcpStream) -> Result<()>

Once an accept_overlapped has finished, this function needs to be called to finish the accept operation.

Currently this just calls setsockopt with SO_UPDATE_ACCEPT_CONTEXT to ensure that further functions like getpeername and getsockname work correctly.

unsafe fn result(&self, overlapped: *mut OVERLAPPED) -> Result<(usize, u32)>

Calls the GetOverlappedResult function to get the result of an overlapped operation for this handle.

This function takes the OVERLAPPED argument which must have been used to initiate an overlapped I/O operation, and returns either the successful number of bytes transferred during the operation or an error if one occurred, along with the results of the lpFlags parameter of the relevant operation, if applicable.

Unsafety

This function is unsafe as overlapped must have previously been used to execute an operation for this handle, and it must also be a valid pointer to an OVERLAPPED instance.

Panics

This function will panic

Loading content...

Implementations on Foreign Types

impl TcpListenerExt for TcpListener[src]

Loading content...

Implementors

Loading content...