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, time: Option<Duration>) -> &mut Self
pub fn set_keepalive(&mut self, time: Option<Duration>) -> &mut Self
Set the duration to remain idle before sending TCP keepalive probes.
If None
is specified, keepalive is disabled.
sourcepub fn set_keepalive_interval(&mut self, interval: Option<Duration>) -> &mut Self
pub fn set_keepalive_interval(&mut self, interval: Option<Duration>) -> &mut Self
Set the duration between two successive TCP keepalive retransmissions, if acknowledgement to the previous keepalive transmission is not received.
sourcepub fn set_keepalive_retries(&mut self, retries: Option<u32>) -> &mut Self
pub fn set_keepalive_retries(&mut self, retries: Option<u32>) -> &mut Self
Set the number of retransmissions to be carried out before declaring that remote end is not available.
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
.