Struct salvo::hyper::server::conn::AddrIncoming [−]
pub struct AddrIncoming { /* fields omitted */ }
Expand description
A stream of connections from binding to an address.
Implementations
impl AddrIncoming
impl AddrIncoming
pub fn bind(addr: &SocketAddr) -> Result<AddrIncoming, Error>
pub fn bind(addr: &SocketAddr) -> Result<AddrIncoming, Error>
Creates a new AddrIncoming
binding to provided socket address.
pub fn from_listener(listener: TcpListener) -> Result<AddrIncoming, Error>
pub fn from_listener(listener: TcpListener) -> Result<AddrIncoming, Error>
Creates a new AddrIncoming
from an existing tokio::net::TcpListener
.
pub fn local_addr(&self) -> SocketAddr
pub fn local_addr(&self) -> SocketAddr
Get the local address bound to this listener.
pub fn set_keepalive(
&mut self,
keepalive: Option<Duration>
) -> &mut AddrIncoming
pub fn set_keepalive(
&mut self,
keepalive: Option<Duration>
) -> &mut AddrIncoming
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.
pub fn set_nodelay(&mut self, enabled: bool) -> &mut AddrIncoming
pub fn set_nodelay(&mut self, enabled: bool) -> &mut AddrIncoming
Set the value of TCP_NODELAY
option for accepted connections.
pub 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
impl Accept for AddrIncoming
impl Accept for AddrIncoming
type Conn = AddrStream
type Conn = AddrStream
The connection type that can be accepted.
pub fn poll_accept(
self: Pin<&mut AddrIncoming>,
cx: &mut Context<'_>
) -> Poll<Option<Result<<AddrIncoming as Accept>::Conn, <AddrIncoming as Accept>::Error>>>
pub fn poll_accept(
self: Pin<&mut AddrIncoming>,
cx: &mut Context<'_>
) -> Poll<Option<Result<<AddrIncoming as Accept>::Conn, <AddrIncoming as Accept>::Error>>>
Poll to accept the next connection.