pub trait AsyncAccept {
    type Connection: AsyncRead + AsyncWrite;
    type Address: Debug;
    type Error: Error;

    // Required method
    fn poll_accept(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>
    ) -> Poll<Result<(Self::Connection, Self::Address), Self::Error>>;
}
Expand description

Asynchronously accept connections.

Required Associated Types§

source

type Connection: AsyncRead + AsyncWrite

The type of the connection that is accepted.

source

type Address: Debug

The type of the remote address, such as std::net::SocketAddr.

If no remote address can be determined (such as for mock connections), () or a similar dummy type can be used.

source

type Error: Error

The type of error that may be returned.

Required Methods§

source

fn poll_accept( self: Pin<&mut Self>, cx: &mut Context<'_> ) -> Poll<Result<(Self::Connection, Self::Address), Self::Error>>

Poll to accept the next connection.

On success return the new connection, and the address of the peer.

Implementations on Foreign Types§

source§

impl AsyncAccept for TcpListener

Available on crate feature tokio-net only.
§

type Connection = TcpStream

§

type Error = Error

§

type Address = SocketAddr

source§

fn poll_accept( self: Pin<&mut Self>, cx: &mut Context<'_> ) -> Poll<Result<(Self::Connection, Self::Address), Self::Error>>

source§

impl AsyncAccept for UnixListener

Available on crate feature tokio-net only.
§

type Connection = UnixStream

§

type Error = Error

§

type Address = SocketAddr

source§

fn poll_accept( self: Pin<&mut Self>, cx: &mut Context<'_> ) -> Poll<Result<(Self::Connection, Self::Address), Self::Error>>

Implementors§