pub struct AddrIncoming { /* private fields */ }
Expand description
A stream of connections from binding to an address.
Implementations
sourceimpl AddrIncoming
impl AddrIncoming
sourcepub fn bind(addr: &SocketAddr) -> Result<Self>
pub fn bind(addr: &SocketAddr) -> Result<Self>
Creates a new AddrIncoming
binding to provided socket address.
sourcepub fn from_listener(listener: TcpListener) -> Result<Self>
pub fn from_listener(listener: TcpListener) -> Result<Self>
Creates a new AddrIncoming
from an existing tokio::net::TcpListener
.
sourcepub fn local_addr(&self) -> SocketAddr
pub fn local_addr(&self) -> SocketAddr
Get the local address bound to this listener.
sourcepub fn set_keepalive(&mut self, keepalive: Option<Duration>) -> &mut Self
pub fn set_keepalive(&mut self, keepalive: Option<Duration>) -> &mut Self
Set whether TCP keepalive messages are enabled on accepted connections.
If None
is specified, keepalive is disabled, otherwise the duration
specified will be the time to remain idle before sending TCP keepalive
probes.
sourcepub fn set_nodelay(&mut self, enabled: bool) -> &mut Self
pub fn set_nodelay(&mut self, enabled: bool) -> &mut Self
Set the value of TCP_NODELAY
option for accepted connections.
sourcepub fn set_sleep_on_errors(&mut self, val: bool)
pub fn set_sleep_on_errors(&mut self, val: bool)
Set whether to sleep on accept errors.
A possible scenario is that the process has hit the max open files
allowed, and so trying to accept a new connection will fail with
EMFILE
. In some cases, it’s preferable to just wait for some time, if
the application will likely close some files (or connections), and try
to accept the connection again. If this option is true
, the error
will be logged at the error
level, since it is still a big deal,
and then the listener will sleep for 1 second.
In other cases, hitting the max open files should be treat similarly
to being out-of-memory, and simply error (and shutdown). Setting
this option to false
will allow that.
Default is true
.
Trait Implementations
sourceimpl Accept for AddrIncoming
impl Accept for AddrIncoming
Auto Trait Implementations
impl !RefUnwindSafe for AddrIncoming
impl Send for AddrIncoming
impl Sync for AddrIncoming
impl Unpin for AddrIncoming
impl !UnwindSafe for AddrIncoming
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
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more