Trait no_std_compat::os::linux::net::TcpStreamExt

source ·
pub trait TcpStreamExt: Sealed {
    // Required methods
    fn set_quickack(&self, quickack: bool) -> Result<(), Error>;
    fn quickack(&self) -> Result<bool, Error>;
    fn set_deferaccept(&self, accept: u32) -> Result<(), Error>;
    fn deferaccept(&self) -> Result<u32, Error>;
}
🔬This is a nightly-only experimental API. (tcp_quickack)
Available on Linux only.
Expand description

Os-specific extensions for TcpStream

Required Methods§

source

fn set_quickack(&self, quickack: bool) -> Result<(), Error>

🔬This is a nightly-only experimental API. (tcp_quickack)

Enable or disable TCP_QUICKACK.

This flag causes Linux to eagerly send ACKs rather than delaying them. Linux may reset this flag after further operations on the socket.

See man 7 tcp and TCP delayed acknowledgement for more information.

§Examples
#![feature(tcp_quickack)]
use std::net::TcpStream;
use std::os::linux::net::TcpStreamExt;

let stream = TcpStream::connect("127.0.0.1:8080")
        .expect("Couldn't connect to the server...");
stream.set_quickack(true).expect("set_quickack call failed");
source

fn quickack(&self) -> Result<bool, Error>

🔬This is a nightly-only experimental API. (tcp_quickack)

Gets the value of the TCP_QUICKACK option on this socket.

For more information about this option, see TcpStreamExt::set_quickack.

§Examples
#![feature(tcp_quickack)]
use std::net::TcpStream;
use std::os::linux::net::TcpStreamExt;

let stream = TcpStream::connect("127.0.0.1:8080")
        .expect("Couldn't connect to the server...");
stream.set_quickack(true).expect("set_quickack call failed");
assert_eq!(stream.quickack().unwrap_or(false), true);
source

fn set_deferaccept(&self, accept: u32) -> Result<(), Error>

🔬This is a nightly-only experimental API. (tcp_deferaccept)

A socket listener will be awakened solely when data arrives.

The accept argument set the delay in seconds until the data is available to read, reducing the number of short lived connections without data to process. Contrary to other platforms SO_ACCEPTFILTER feature equivalent, there is no necessity to set it after the listen call.

See man 7 tcp

§Examples
#![feature(tcp_deferaccept)]
use std::net::TcpStream;
use std::os::linux::net::TcpStreamExt;

let stream = TcpStream::connect("127.0.0.1:8080")
        .expect("Couldn't connect to the server...");
stream.set_deferaccept(1).expect("set_deferaccept call failed");
source

fn deferaccept(&self) -> Result<u32, Error>

🔬This is a nightly-only experimental API. (tcp_deferaccept)

Gets the accept delay value (in seconds) of the TCP_DEFER_ACCEPT option.

For more information about this option, see TcpStreamExt::set_deferaccept.

§Examples
#![feature(tcp_deferaccept)]
use std::net::TcpStream;
use std::os::linux::net::TcpStreamExt;

let stream = TcpStream::connect("127.0.0.1:8080")
        .expect("Couldn't connect to the server...");
stream.set_deferaccept(1).expect("set_deferaccept call failed");
assert_eq!(stream.deferaccept().unwrap_or(0), 1);

Implementors§