Struct rotor::mio::tcp::TcpListener [] [src]

pub struct TcpListener {
    // some fields omitted
}

Methods

impl TcpListener

fn bind(addr: &SocketAddr) -> Result<TcpListener, Error>

Convenience method to bind a new TCP listener to the specified address to receive new connections.

This function will take the following steps:

  1. Create a new TCP socket.
  2. Set the SO_REUSEADDR option on the socket.
  3. Bind the socket to the specified address.
  4. Call listen on the socket to prepare it to receive new connections.

If fine-grained control over the binding and listening process for a socket is desired then the net2::TcpBuilder methods can be used in combination with the TcpListener::from_listener method to transfer ownership into mio.

fn from_listener(listener: TcpListener, addr: &SocketAddr) -> Result<TcpListener, Error>

Creates a new TcpListener from an instance of a std::net::TcpListener type.

This function will set the listener provided into nonblocking mode on Unix, and otherwise the stream will just be wrapped up in an mio stream ready to accept new connections and become associated with an event loop.

The address provided must be the address that the listener is bound to.

fn accept(&self) -> Result<Option<(TcpStream, SocketAddr)>, Error>

Accepts a new TcpStream.

Returns a Ok(None) when the socket WOULDBLOCK, this means the stream will be ready at a later point. If an accepted stream is returned, the address of the peer is returned along with it

fn local_addr(&self) -> Result<SocketAddr, Error>

fn try_clone(&self) -> Result<TcpListener, Error>

fn take_socket_error(&self) -> Result<(), Error>

Trait Implementations

impl TryAccept for TcpListener

type Output = TcpStream

fn accept(&self) -> Result<Option<TcpStream>, Error>

impl Evented for TcpListener

fn register(&self, selector: &mut Selector, token: Token, interest: EventSet, opts: PollOpt) -> Result<(), Error>

fn reregister(&self, selector: &mut Selector, token: Token, interest: EventSet, opts: PollOpt) -> Result<(), Error>

fn deregister(&self, selector: &mut Selector) -> Result<(), Error>

impl FromRawFd for TcpListener

unsafe fn from_raw_fd(fd: i32) -> TcpListener

impl AsRawFd for TcpListener

fn as_raw_fd(&self) -> i32

Derived Implementations

impl Debug for TcpListener

fn fmt(&self, __arg_0: &mut Formatter) -> Result<(), Error>