pub struct TcpListener { /* private fields */ }
Expand description
A socket listening on a TCP port.
The TcpListener::accept
method is meant to be used in async contexts.
Implementations
sourceimpl TcpListener
impl TcpListener
sourcepub fn try_new(ns: &Namespace, addr: &SocketAddr) -> Result<Self>
pub fn try_new(ns: &Namespace, addr: &SocketAddr) -> Result<Self>
Creates a new TCP listener.
It is configured to listen on the given socket address for the given namespace.
Methods from Deref<Target = TcpListener>
sourcepub fn accept(&self, block: bool) -> Result<TcpStream>
pub fn accept(&self, block: bool) -> Result<TcpStream>
Accepts a new connection.
On success, returns the newly-accepted socket stream.
If no connection is available to be accepted, one of two behaviours will occur:
- If
block
isfalse
, returnscrate::error::code::EAGAIN
; - If
block
istrue
, blocks until an error occurs or some connection can be accepted.
Trait Implementations
sourceimpl Deref for TcpListener
impl Deref for TcpListener
type Target = TcpListener
type Target = TcpListener
The resulting type after dereferencing.
Auto Trait Implementations
impl RefUnwindSafe for TcpListener
impl Send for TcpListener
impl Sync for TcpListener
impl Unpin for TcpListener
impl UnwindSafe for TcpListener
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more