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

pub struct TcpListener { /* fields omitted */ }

Methods

impl TcpListener
[src]

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.

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.

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

Returns the local socket address of this listener.

Creates a new independently owned handle to the underlying socket.

The returned TcpListener is a reference to the same socket that this object references. Both handles can be used to accept incoming connections and options set on one listener will affect the other.

Sets the value for the IP_TTL option on this socket.

This value sets the time-to-live field that is used in every packet sent from this socket.

Gets the value of the IP_TTL option for this socket.

For more information about this option, see set_ttl.

Sets the value for the IPV6_V6ONLY option on this socket.

If this is set to true then the socket is restricted to sending and receiving IPv6 packets only. In this case two IPv4 and IPv6 applications can bind the same port at the same time.

If this is set to false then the socket can be used to send and receive packets from an IPv4-mapped IPv6 address.

Gets the value of the IPV6_V6ONLY option for this socket.

For more information about this option, see set_only_v6.

Get the value of the SO_ERROR option on this socket.

This will retrieve the stored error in the underlying socket, clearing the field in the process. This can be useful for checking errors between calls.

Trait Implementations

impl Debug for TcpListener
[src]

Formats the value using the given formatter.

impl Evented for TcpListener
[src]

impl IntoRawFd for TcpListener
[src]

Consumes this object, returning the raw underlying file descriptor. Read more

impl AsRawFd for TcpListener
[src]

Extracts the raw file descriptor. Read more

impl FromRawFd for TcpListener
[src]

Constructs a new instances of Self from the given raw file descriptor. Read more