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::newperforms asocketand returns a newTcpListenerthat is not yet bound.Pool::bind_existing_tcp_listenerperforms abind, checking that the address is in thePool.TcpListenerExt::listenperforms alisten.- Then, the regular
TcpListener::acceptmay be used to accept new connections. Alternatively,TcpListener::accept_withmay be used.
and the following sequence for initiating outgoing connections:
TcpListenerExt::newperforms asocketand returns a newTcpListenerthat is not yet connected.Pool::connect_into_tcp_streamperforms 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::newandUdpSocketExt::new. - Select blocking or non-blocking mode.
Traits
- A trait for extending
Pooltypes. - A trait for extending
TcpListenertypes. - A trait for extending
UdpSockettypes.