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.
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.
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.
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.
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Source§RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4