Struct hyper::server::conn::AddrIncoming

source ·
pub struct AddrIncoming {
    addr: SocketAddr,
    listener: TcpListener,
    sleep_on_errors: bool,
    tcp_keepalive_config: TcpKeepaliveConfig,
    tcp_nodelay: bool,
    timeout: Option<Pin<Box<Sleep>>>,
}
Expand description

A stream of connections from binding to an address.

Fields§

§addr: SocketAddr§listener: TcpListener§sleep_on_errors: bool§tcp_keepalive_config: TcpKeepaliveConfig§tcp_nodelay: bool§timeout: Option<Pin<Box<Sleep>>>

Implementations§

source§

impl AddrIncoming

source

pub(super) fn new(addr: &SocketAddr) -> Result<Self>

source

pub(super) fn from_std(std_listener: StdTcpListener) -> Result<Self>

source

pub fn bind(addr: &SocketAddr) -> Result<Self>

Creates a new AddrIncoming binding to provided socket address.

source

pub fn from_listener(listener: TcpListener) -> Result<Self>

Creates a new AddrIncoming from an existing tokio::net::TcpListener.

source

pub fn local_addr(&self) -> SocketAddr

Get the local address bound to this listener.

source

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.

source

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.

source

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.

source

pub fn set_nodelay(&mut self, enabled: bool) -> &mut Self

Set the value of TCP_NODELAY option for accepted connections.

source

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.

source

fn poll_next_(&mut self, cx: &mut Context<'_>) -> Poll<Result<AddrStream>>

Trait Implementations§

source§

impl Accept for AddrIncoming

§

type Conn = AddrStream

The connection type that can be accepted.
§

type Error = Error

The error type that can occur when accepting a connection.
source§

fn poll_accept( self: Pin<&mut Self>, cx: &mut Context<'_> ) -> Poll<Option<Result<Self::Conn, Self::Error>>>

Poll to accept the next connection.
source§

impl Debug for AddrIncoming

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more