cap_net_ext

Trait TcpListenerExt

Source
pub trait TcpListenerExt: Sealed + Sized {
    // Required methods
    fn new(address_family: AddressFamily, blocking: Blocking) -> Result<Self>;
    fn listen(&self, backlog: Option<i32>) -> Result<()>;
    fn accept_with(&self, blocking: Blocking) -> Result<(TcpStream, SocketAddr)>;
}
Expand description

A trait for extending TcpListener types.

Required Methods§

Source

fn new(address_family: AddressFamily, blocking: Blocking) -> Result<Self>

Creates a new TCP socket with the given address family.

The created socket is not bound or connected to any address and may be used for either listening or connecting. Use PoolExt::bind_existing_tcp_listener to bind it in preparation for listening, or PoolExt::connect_into_tcp_stream to initiate a connection.

This is similar to Pool::bind_tcp_listener in that it creates a TCP socket, however it does not perform the bind or listen steps. And, it has a blocking argument to select blocking or non-blocking mode for the created socket.

And it’s similar to Pool::connect_tcp_stream in that it creates a TCP socket, however it does not perform the connect step. And, it has a blocking argument to select blocking or non-blocking mode for the created socket.

Source

fn listen(&self, backlog: Option<i32>) -> Result<()>

Enble listening in a TcpListener.

A newly-created TcpListener created with TcpListenerExt::new and bound with PoolExt::bind_existing_tcp_listener is not yet listening; this function enables listening. After this, the listener may accept new connections with accept or accept_with.

This is similar to Pool::bind_tcp_listener in that it performs the listen step, however it does not create the socket itself, or bind it.

The backlog argument specifies an optional hint to the implementation about how many connections can be waiting before new connections are refused or ignored.

Source

fn accept_with(&self, blocking: Blocking) -> Result<(TcpStream, SocketAddr)>

Similar to accept, but the resulting TCP connection are optionally set to non-blocking mode.

The accept call itself may still block, if the socket is in blocking mode.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl TcpListenerExt for TcpListener

Source§

fn new(address_family: AddressFamily, blocking: Blocking) -> Result<Self>

Source§

fn listen(&self, backlog: Option<i32>) -> Result<()>

Source§

fn accept_with(&self, blocking: Blocking) -> Result<(TcpStream, SocketAddr)>

Implementors§