pub struct TcpListener { /* private fields */ }Expand description
Native async TCP listener with connection management
Implementations§
Source§impl TcpListener
impl TcpListener
Sourcepub async fn bind(addr: &str) -> Result<TcpListener, Error>
pub async fn bind(addr: &str) -> Result<TcpListener, Error>
Bind to an address with default configuration
Sourcepub async fn bind_with_config(
addr: &str,
config: TcpServerConfig,
) -> Result<TcpListener, Error>
pub async fn bind_with_config( addr: &str, config: TcpServerConfig, ) -> Result<TcpListener, Error>
Bind to an address with custom configuration
Sourcepub async fn accept(&self) -> Result<(TcpStream, SocketAddr), Error>
pub async fn accept(&self) -> Result<(TcpStream, SocketAddr), Error>
Accept the next incoming connection
Sourcepub fn stats(&self) -> TcpServerStats
pub fn stats(&self) -> TcpServerStats
Get server statistics
Sourcepub fn local_addr(&self) -> Result<SocketAddr, Error>
pub fn local_addr(&self) -> Result<SocketAddr, Error>
Return the local socket address this listener is bound to.
Auto Trait Implementations§
impl Freeze for TcpListener
impl RefUnwindSafe for TcpListener
impl Send for TcpListener
impl Sync for TcpListener
impl Unpin for TcpListener
impl UnsafeUnpin for TcpListener
impl UnwindSafe for TcpListener
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more