Struct safina::net::TcpListener
source · [−]pub struct TcpListener { /* private fields */ }
Expand description
Async wrapper around
std::net::TcpListener
.
Implementations
sourceimpl TcpListener
impl TcpListener
sourcepub fn new(std_listener: TcpListener) -> Result<TcpListener, Error>
pub fn new(std_listener: TcpListener) -> Result<TcpListener, Error>
Wraps an existing listener socket so we can perform async operations on it.
Errors
Returns any
Err(std::io::Error)
returned by
std::net::TcpListener::set_nonblocking
.
sourcepub fn bind<A>(addr: A) -> Result<TcpListener, Error> where
A: ToSocketAddrs,
pub fn bind<A>(addr: A) -> Result<TcpListener, Error> where
A: ToSocketAddrs,
Returns a TCP listener socket, bound to addr
, that is ready to accept connections.
Errors
Returns any
Err(std::io::Error)
returned by the underlying
std::net::TcpListener::bind
method.
pub fn inner(&self) -> &TcpListener
pub fn into_inner(self) -> TcpListener
sourcepub fn try_clone(&self) -> Result<TcpListener, Error>
pub fn try_clone(&self) -> Result<TcpListener, Error>
Makes a new handle to this socket.
Errors
Returns any
Err(std::io::Error)
returned by the underlying
std::net::TcpListener::try_clone
method.
sourcepub async fn accept(&'_ self) -> Result<(TcpStream, SocketAddr), Error>
pub async fn accept(&'_ self) -> Result<(TcpStream, SocketAddr), Error>
Waits for a new connection and then accepts it. Returns the address of the remote side of the connection and a stream for reading and writing the connection.
Errors
Returns an error if it fails to create a new socket. This happens when the process runs out of file descriptors.
Trait Implementations
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