Trait tor_rtcompat::TcpListener
source · [−]pub trait TcpListener {
type TcpStream: AsyncRead + AsyncWrite + Send + Sync + Unpin + 'static;
type Incoming: Stream<Item = IoResult<(Self::TcpStream, SocketAddr)>> + Unpin;
fn accept<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = IoResult<(Self::TcpStream, SocketAddr)>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn incoming(self) -> Self::Incoming;
fn local_addr(&self) -> IoResult<SocketAddr>;
}
Expand description
Trait for a local socket that accepts incoming TCP streams.
These objects are returned by instances of TcpProvider
. To use
one, either call accept
to accept a single connection, or
use incoming
to wrap this object as a stream::Stream
.
Required Associated Types
The type of TCP connections returned by Self::accept()
.
The type of stream::Stream
returned by Self::incoming()
.
Required Methods
Wait for an incoming stream; return it along with its address.
Wrap this listener into a new stream::Stream
that yields
TCP streams and addresses.
fn local_addr(&self) -> IoResult<SocketAddr>
fn local_addr(&self) -> IoResult<SocketAddr>
Return the local address that this listener is bound to.