Struct nbio::tcp::TcpServer

source ·
pub struct TcpServer { /* private fields */ }
Expand description

A TcpServer, which produces connected, nonblocking TcpSession on calling accept.

Implementations§

source§

impl TcpServer

source

pub fn new(listener: TcpListener) -> Self

Encapsulate the given TcpListener

source

pub fn bind<A: ToSocketAddrs>(addr: A) -> Result<Self, Error>

Bind to the given socket address in nonblocking mode.

source

pub fn set_nonblocking(&self, nonblocking: bool) -> Result<(), Error>

Set nonblocking on the listener

source

pub fn set_ttl(&self, ttl: u32) -> Result<(), Error>

Set ttl on the listener

source

pub fn with_nonblocking(self, nonblocking: bool) -> Result<Self, Error>

Set nonblocking on the listener using a builder pattern

source

pub fn with_ttl(self, ttl: u32) -> Result<Self, Error>

Set ttl on the listener using a builder pattern

source

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§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V