pub struct TcpListener(/* private fields */);
Expand description
An I/O object representing a TCP socket listening for incoming connections.
This object can be converted into a stream of incoming connections for various forms of processing.
Implementations§
Source§impl TcpListener
impl TcpListener
Sourcepub fn bind(addr: &SocketAddr) -> Result<TcpListener>
pub fn bind(addr: &SocketAddr) -> Result<TcpListener>
Creates a new TcpListener
bound to the provided socket.
Sourcepub fn accept(self) -> Acceptor ⓘ
pub fn accept(self) -> Acceptor ⓘ
Consumes this listener and returns a Future
that resolves to an
io::Result<(TcpListener, TcpStream, SocketAddr)>
.
Sourcepub fn accept_stream(self) -> AcceptStream
pub fn accept_stream(self) -> AcceptStream
Consumes this listener and returns a Stream
that resolves to elements
of type io::Result<(TcpStream, SocketAddr)>
.
Sourcepub fn async_accept(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Result<(TcpStream, SocketAddr)>>
pub fn async_accept( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(TcpStream, SocketAddr)>>
Poll on accept
ing a new TcpStream
from this listener.
This function is mainly intended for usage in manual Future
or Stream
implementations.
Sourcepub fn from_std(listener: TcpListener) -> Result<TcpListener>
pub fn from_std(listener: TcpListener) -> Result<TcpListener>
Creates a new instance of fuchsia_async::net::TcpListener
from an
std::net::TcpListener
.
Sourcepub fn std(&self) -> &TcpListener
pub fn std(&self) -> &TcpListener
Returns a reference to the underlying std::net::TcpListener
.
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Returns the local socket address of the listener.
Methods from Deref<Target = EventedFd<TcpListener>>§
Sourcepub fn poll_readable(&self, cx: &mut Context<'_>) -> Poll<Result<(), Status>>
pub fn poll_readable(&self, cx: &mut Context<'_>) -> Poll<Result<(), Status>>
Tests to see if this resource is ready to be read from. If it is not, it arranges for the current task to receive a notification when a “readable” signal arrives.
Sourcepub fn poll_writable(&self, cx: &mut Context<'_>) -> Poll<Result<(), Status>>
pub fn poll_writable(&self, cx: &mut Context<'_>) -> Poll<Result<(), Status>>
Tests to see if this resource is ready to be written to. If it is not, it arranges for the current task to receive a notification when a “writable” signal arrives.
pub fn as_ref(&self) -> &T
Sourcepub fn need_read(&self, cx: &mut Context<'_>)
pub fn need_read(&self, cx: &mut Context<'_>)
Arranges for the current task to receive a notification when a “readable” signal arrives.
Sourcepub fn need_write(&self, cx: &mut Context<'_>)
pub fn need_write(&self, cx: &mut Context<'_>)
Arranges for the current task to receive a notification when a “writable” signal arrives.