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

pub trait TcpListenerExt {
    unsafe fn accept_overlapped(&self,
                                socket: &TcpBuilder,
                                addrs: &mut AcceptAddrsBuf,
                                overlapped: &mut Overlapped)
                                -> Result<(TcpStream, bool)>; fn accept_complete(&self, socket: &TcpStream) -> Result<()>; }

Additional methods for the TcpListener type in the standard library.

Required Methods

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(stream, true) is returned. If the connect indicates that the I/O is currently pending, Ok(stream, 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.

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.

Implementors