pub struct TcpServer { /* private fields */ }
Expand description
A TcpServer, which produces connected, nonblocking TcpSession
on calling accept
.
Implementations§
source§impl TcpServer
impl TcpServer
sourcepub fn new(listener: TcpListener) -> Self
pub fn new(listener: TcpListener) -> Self
Encapsulate the given TcpListener
sourcepub fn bind<A: ToSocketAddrs>(addr: A) -> Result<Self, Error>
pub fn bind<A: ToSocketAddrs>(addr: A) -> Result<Self, Error>
Bind to the given socket address in nonblocking mode.
sourcepub fn set_nonblocking(&self, nonblocking: bool) -> Result<(), Error>
pub fn set_nonblocking(&self, nonblocking: bool) -> Result<(), Error>
Set nonblocking on the listener
sourcepub fn with_nonblocking(self, nonblocking: bool) -> Result<Self, Error>
pub fn with_nonblocking(self, nonblocking: bool) -> Result<Self, Error>
Set nonblocking on the listener using a builder pattern
sourcepub fn with_ttl(self, ttl: u32) -> Result<Self, Error>
pub fn with_ttl(self, ttl: u32) -> Result<Self, Error>
Set ttl on the listener using a builder pattern
sourcepub fn accept(&self) -> Result<Option<(TcpSession, SocketAddr)>, Error>
pub fn accept(&self) -> Result<Option<(TcpSession, SocketAddr)>, Error>
Accept a new TCP Session, immediately returning None in nonblocking mode if there are no new sessions.
Auto Trait Implementations§
impl Freeze for TcpServer
impl RefUnwindSafe for TcpServer
impl Send for TcpServer
impl Sync for TcpServer
impl Unpin for TcpServer
impl UnwindSafe for TcpServer
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