Trait net2::TcpStreamExt [] [src]

pub trait TcpStreamExt {
    fn set_nodelay(&self, nodelay: bool) -> Result<()>;
    fn nodelay(&self) -> Result<bool>;
    fn set_recv_buffer_size(&self, size: usize) -> Result<()>;
    fn recv_buffer_size(&self) -> Result<usize>;
    fn set_send_buffer_size(&self, size: usize) -> Result<()>;
    fn send_buffer_size(&self) -> Result<usize>;
    fn set_keepalive_ms(&self, keepalive: Option<u32>) -> Result<()>;
    fn keepalive_ms(&self) -> Result<Option<u32>>;
    fn set_keepalive(&self, keepalive: Option<Duration>) -> Result<()>;
    fn keepalive(&self) -> Result<Option<Duration>>;
    fn set_read_timeout_ms(&self, val: Option<u32>) -> Result<()>;
    fn set_read_timeout(&self, val: Option<Duration>) -> Result<()>;
    fn read_timeout_ms(&self) -> Result<Option<u32>>;
    fn read_timeout(&self) -> Result<Option<Duration>>;
    fn set_write_timeout_ms(&self, val: Option<u32>) -> Result<()>;
    fn set_write_timeout(&self, val: Option<Duration>) -> Result<()>;
    fn write_timeout_ms(&self) -> Result<Option<u32>>;
    fn write_timeout(&self) -> Result<Option<Duration>>;
    fn set_ttl(&self, ttl: u32) -> Result<()>;
    fn ttl(&self) -> Result<u32>;
    fn set_only_v6(&self, only_v6: bool) -> Result<()>;
    fn only_v6(&self) -> Result<bool>;
    fn connect<T: ToSocketAddrs>(&self, addr: T) -> Result<()>;
    fn take_error(&self) -> Result<Option<Error>>;
    fn set_nonblocking(&self, nonblocking: bool) -> Result<()>;
    fn set_linger(&self, dur: Option<Duration>) -> Result<()>;
    fn linger(&self) -> Result<Option<Duration>>;
}

Extension methods for the standard TcpStream type in std::net.

Required Methods

Sets the value of the TCP_NODELAY option on this socket.

If set, this option disables the Nagle algorithm. This means that segments are always sent as soon as possible, even if there is only a small amount of data. When not set, data is buffered until there is a sufficient amount to send out, thereby avoiding the frequent sending of small packets.

Gets the value of the TCP_NODELAY option on this socket.

For more information about this option, see set_nodelay.

Sets the value of the SO_RCVBUF option on this socket.

Changes the size of the operating system's receive buffer associated with the socket.

Gets the value of the SO_RCVBUF option on this socket.

For more information about this option, see set_recv_buffer_size.

Sets the value of the SO_SNDBUF option on this socket.

Changes the size of the operating system's send buffer associated with the socket.

Gets the value of the SO_SNDBUF option on this socket.

For more information about this option, see set_send_buffer.

Sets whether keepalive messages are enabled to be sent on this socket.

On Unix, this option will set the SO_KEEPALIVE as well as the TCP_KEEPALIVE or TCP_KEEPIDLE option (depending on your platform). On Windows, this will set the SIO_KEEPALIVE_VALS option.

If None is specified then keepalive messages are disabled, otherwise the number of milliseconds specified will be the time to remain idle before sending a TCP keepalive probe.

Some platforms specify this value in seconds, so sub-second millisecond specifications may be omitted.

Returns whether keepalive messages are enabled on this socket, and if so the amount of milliseconds between them.

For more information about this option, see set_keepalive_ms.

Sets whether keepalive messages are enabled to be sent on this socket.

On Unix, this option will set the SO_KEEPALIVE as well as the TCP_KEEPALIVE or TCP_KEEPIDLE option (depending on your platform). On Windows, this will set the SIO_KEEPALIVE_VALS option.

If None is specified then keepalive messages are disabled, otherwise the duration specified will be the time to remain idle before sending a TCP keepalive probe.

Some platforms specify this value in seconds, so sub-second specifications may be omitted.

Returns whether keepalive messages are enabled on this socket, and if so the duration of time between them.

For more information about this option, see set_keepalive.

Sets the SO_RCVTIMEO option for this socket.

This option specifies the timeout, in milliseconds, of how long calls to this socket's read function will wait before returning a timeout. A value of None means that no read timeout should be specified and otherwise Some indicates the number of milliseconds for the timeout.

Sets the SO_RCVTIMEO option for this socket.

This option specifies the timeout of how long calls to this socket's read function will wait before returning a timeout. A value of None means that no read timeout should be specified and otherwise Some indicates the number of duration of the timeout.

Gets the value of the SO_RCVTIMEO option for this socket.

For more information about this option, see set_read_timeout_ms.

Gets the value of the SO_RCVTIMEO option for this socket.

For more information about this option, see set_read_timeout.

Sets the SO_SNDTIMEO option for this socket.

This option specifies the timeout, in milliseconds, of how long calls to this socket's write function will wait before returning a timeout. A value of None means that no read timeout should be specified and otherwise Some indicates the number of milliseconds for the timeout.

Sets the SO_SNDTIMEO option for this socket.

This option specifies the timeout of how long calls to this socket's write function will wait before returning a timeout. A value of None means that no read timeout should be specified and otherwise Some indicates the duration of the timeout.

Gets the value of the SO_SNDTIMEO option for this socket.

For more information about this option, see set_write_timeout_ms.

Gets the value of the SO_SNDTIMEO option for this socket.

For more information about this option, see set_write_timeout.

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.

Executes a connect operation on this socket, establishing a connection to the host specified by addr.

Note that this normally does not need to be called on a TcpStream, it's typically automatically done as part of a normal TcpStream::connect function call or TcpBuilder::connect method call.

This should only be necessary if an unconnected socket was extracted from a TcpBuilder and then needs to be connected.

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.

Moves this TCP stream into or out of nonblocking mode.

On Unix this corresponds to calling fcntl, and on Windows this corresponds to calling ioctlsocket.

Sets the linger duration of this socket by setting the SO_LINGER option

reads the linger duration for this socket by getting the SO_LINGER option

Implementors