[][src]Struct libuv::handles::streams::tcp::TcpHandle

pub struct TcpHandle { /* fields omitted */ }

TCP handles are used to represent both TCP streams and servers.

Implementations

impl TcpHandle[src]

pub fn new(r#loop: &Loop) -> Result<TcpHandle>[src]

Initialize the handle. No socket is created as of yet.

pub fn new_ex(r#loop: &Loop, flags: TcpFlags) -> Result<TcpHandle>[src]

Initialize the handle with the specified flags. A socket will be created for the given domain. If the specified domain is AF_UNSPEC no socket is created, just like new().

pub fn nodelay(&mut self, enable: bool) -> Result<()>[src]

Enable TCP_NODELAY, which disables Nagle’s algorithm.

pub fn keepalive(&mut self, enable: bool, delay: u32) -> Result<()>[src]

Enable / disable TCP keep-alive. delay is the initial delay in seconds, ignored when enable is zero.

After delay has been reached, 10 successive probes, each spaced 1 second from the previous one, will still happen. If the connection is still lost at the end of this procedure, then the handle is destroyed with a ETIMEDOUT error passed to the corresponding callback.

pub fn simultaneous_accepts(&mut self, enable: bool) -> Result<()>[src]

Enable / disable simultaneous asynchronous accept requests that are queued by the operating system when listening for new TCP connections.

This setting is used to tune a TCP server for the desired performance. Having simultaneous accepts can significantly improve the rate of accepting connections (which is why it is enabled by default) but may lead to uneven load distribution in multi-process setups.

pub fn bind(
    &mut self,
    addr: &SocketAddr,
    flags: TcpBindFlags
) -> Result<(), Box<dyn Error>>
[src]

Bind the handle to an address and port.

When the port is already taken, you can expect to see an EADDRINUSE error from either bind(), listen() or connect(). That is, a successful call to this function does not guarantee that the call to listen() or connect() will succeed as well.

flags can contain IPV6ONLY, in which case dual-stack support is disabled and only IPv6 is used.

pub fn getsockname(&self) -> Result<SocketAddr, Box<dyn Error>>[src]

Get the current address to which the handle is bound.

pub fn getpeername(&self) -> Result<SocketAddr, Box<dyn Error>>[src]

Get the address of the peer connected to the handle.

pub fn connect<CB: Into<ConnectCB<'static>>>(
    &mut self,
    addr: &SocketAddr,
    cb: CB
) -> Result<ConnectReq, Box<dyn Error>>
[src]

Establish an IPv4 or IPv6 TCP connection.

On Windows if the addr is initialized to point to an unspecified address (0.0.0.0 or ::) it will be changed to point to localhost. This is done to match the behavior of Linux systems.

The callback is made when the connection has been established or when a connection error happened.

pub fn close_reset<CB: Into<CloseCB<'static>>>(&mut self, cb: CB) -> Result<()>[src]

Resets a TCP connection by sending a RST packet. This is accomplished by setting the SO_LINGER socket option with a linger interval of zero and then calling close(). Due to some platform inconsistencies, mixing of shutdown() and close_reset() calls is not allowed.

Trait Implementations

impl Clone for TcpHandle[src]

impl Copy for TcpHandle[src]

impl From<TcpHandle> for StreamHandle[src]

impl From<TcpHandle> for Handle[src]

impl HandleTrait for TcpHandle[src]

impl StreamTrait for TcpHandle[src]

impl ToHandle for TcpHandle[src]

impl ToStream for TcpHandle[src]

impl TryFrom<Handle> for TcpHandle[src]

type Error = ConversionError

The type returned in the event of a conversion error.

impl TryFrom<StreamHandle> for TcpHandle[src]

type Error = ConversionError

The type returned in the event of a conversion error.

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.