Crate cap_net_ext
source ·Expand description
Extension traits for TcpListener
, UdpSocket
, and Pool
.
cap-std’s TcpListener
, following the Rust standard library
TcpListener
, combines the socket
, bind
, listen
, and connect
operations of the POSIX socket API into a single bind
or connect
operation. In some use cases, it’s desirable to perform the steps
separately.
This API adds extension traits to cap-std’s TcpListener
, UdpSocket
,
and Pool
which support the following sequence for accepting incoming
connections:
TcpListenerExt::new
performs asocket
and returns a newTcpListener
that is not yet bound.Pool::bind_existing_tcp_listener
performs abind
, checking that the address is in thePool
.TcpListenerExt::listen
performs alisten
.- Then, the regular
TcpListener::accept
may be used to accept new connections. Alternatively,TcpListener::accept_with
may be used.
and the following sequence for initiating outgoing connections:
TcpListenerExt::new
performs asocket
and returns a newTcpListener
that is not yet connected.Pool::connect_into_tcp_stream
performs aconnect
, checking that the address is in thePool
.
TcpListenerExt::new
and TcpListener::accept_with
additionally
have Blocking
arguments for requesting non-blocking operation.
Similar API adaptations are available for UDP sockets as well.
Structs§
- A utility for binding TCP listeners.
- A utility for making TCP connections.
- A utility for binding UDP sockets.
- A utility for making UDP connections.
Enums§
- Address families supported by
TcpListenerExt::new
andUdpSocketExt::new
. - Select blocking or non-blocking mode.
Traits§
- A trait for extending
Pool
types. - A trait for extending
TcpListener
types. - A trait for extending
UdpSocket
types.