[][src]Struct mio::net::TcpSocket

pub struct TcpSocket { /* fields omitted */ }
This is supported on crate features tcp or udp or uds only.

A non-blocking TCP socket used to configure a stream or listener.

The TcpSocket type wraps the operating-system's socket handle. This type is used to configure the socket before establishing a connection or start listening for inbound connections.

The socket will be closed when the value is dropped.

Implementations

impl TcpSocket[src]

pub fn new_v4() -> Result<TcpSocket>[src]

This is supported on (crate features tcp or udp or uds) and crate feature tcp only.

Create a new IPv4 TCP socket.

This calls socket(2).

pub fn new_v6() -> Result<TcpSocket>[src]

This is supported on (crate features tcp or udp or uds) and crate feature tcp only.

Create a new IPv6 TCP socket.

This calls socket(2).

pub fn bind(&self, addr: SocketAddr) -> Result<()>[src]

This is supported on (crate features tcp or udp or uds) and crate feature tcp only.

Bind addr to the TCP socket.

pub fn connect(self, addr: SocketAddr) -> Result<TcpStream>[src]

This is supported on (crate features tcp or udp or uds) and crate feature tcp only.

Connect the socket to addr.

This consumes the socket and performs the connect operation. Once the connection completes, the socket is now a non-blocking TcpStream and can be used as such.

pub fn listen(self, backlog: u32) -> Result<TcpListener>[src]

This is supported on (crate features tcp or udp or uds) and crate feature tcp only.

Listen for inbound connections, converting the socket to a TcpListener.

pub fn set_reuseaddr(&self, reuseaddr: bool) -> Result<()>[src]

This is supported on (crate features tcp or udp or uds) and crate feature tcp only.

Sets the value of SO_REUSEADDR on this socket.

Trait Implementations

impl AsRawFd for TcpSocket[src]

impl Debug for TcpSocket[src]

impl Drop for TcpSocket[src]

impl FromRawFd for TcpSocket[src]

unsafe fn from_raw_fd(fd: RawFd) -> TcpSocket[src]

Converts a RawFd to a TcpSocket.

Notes

The caller is responsible for ensuring that the socket is in non-blocking mode.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.