Trait TcpListenerAcceptTimeout

Source
pub trait TcpListenerAcceptTimeout {
    // Required methods
    fn accept_timeout(
        &self,
        timeout: Option<Duration>,
    ) -> Option<IoResult<(TcpStream, SocketAddr)>>;
    fn connection_pending(&self, timeout: Option<Duration>) -> bool;
}
Expand description

TcpListener::accept_timeout() and TcpListener::connection_pending().

Required Methods§

Source

fn accept_timeout( &self, timeout: Option<Duration>, ) -> Option<IoResult<(TcpStream, SocketAddr)>>

Returns either None after a time-out, or accept().

This is not actually a primitive provided for sockets, so if at least one thread is using accept_timeout() simultaneously with any other using accept() or accept_timeout() then:

  • if non-blocking, Some(Err(ErrorKind::WouldBlock)) may still be returned
  • if blocking, this may still sleep

since this thread may wake up because there’s a connection pending, then another thread may accept it, and this thread is left in accept().

Source

fn connection_pending(&self, timeout: Option<Duration>) -> bool

True if accept() on this TcpListener will return successfully without blocking.

A time-out of None waits forever until the condition is met (or an error occurs);
a time-out of Some(Duration::ZERO) never sleeps.

Equivalent to ppoll([{&self, POLLIN}], timeout.unwrap_or(NULL)) == {1, POLLIN}.

Implementations on Foreign Types§

Source§

impl TcpListenerAcceptTimeout for TcpListener

Implementors§