[−][src]Struct mio::net::TcpSocket
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]
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]
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]
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]
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]
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]
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
impl RefUnwindSafe for TcpSocket
impl Send for TcpSocket
impl Sync for TcpSocket
impl Unpin for TcpSocket
impl UnwindSafe for TcpSocket
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,