Struct TcpConfig

Source
pub struct TcpConfig {
Show 13 fields pub socket_family: SocketFamily, pub socket_type: TcpSocketType, pub bind_addr: Option<SocketAddr>, pub nonblocking: bool, pub reuseaddr: Option<bool>, pub nodelay: Option<bool>, pub linger: Option<Duration>, pub ttl: Option<u32>, pub hoplimit: Option<u32>, pub read_timeout: Option<Duration>, pub write_timeout: Option<Duration>, pub bind_device: Option<String>, pub keepalive: Option<bool>,
}
Expand description

Configuration options for a TCP socket.

Fields§

§socket_family: SocketFamily

The socket family, either IPv4 or IPv6.

§socket_type: TcpSocketType

The type of TCP socket, either STREAM or RAW.

§bind_addr: Option<SocketAddr>

Optional address to bind the socket to.

§nonblocking: bool

Whether the socket should be non-blocking.

§reuseaddr: Option<bool>

Whether to allow address reuse.

§nodelay: Option<bool>

Whether to disable Nagle’s algorithm (TCP_NODELAY).

§linger: Option<Duration>

Optional linger duration for the socket.

§ttl: Option<u32>

Optional Time-To-Live (TTL) for the socket.

§hoplimit: Option<u32>

Optional Hop Limit for the socket (IPv6).

§read_timeout: Option<Duration>

Optional read timeout for the socket.

§write_timeout: Option<Duration>

Optional write timeout for the socket.

§bind_device: Option<String>

Optional device to bind the socket to.

§keepalive: Option<bool>

Whether to enable TCP keepalive.

Implementations§

Source§

impl TcpConfig

Source

pub fn v4_stream() -> Self

Create a STREAM socket for IPv4.

Source

pub fn raw_v4() -> Self

Create a RAW socket. Requires administrator privileges.

Source

pub fn v6_stream() -> Self

Create a STREAM socket for IPv6.

Source

pub fn raw_v6() -> Self

Create a RAW socket for IPv6. Requires administrator privileges.

Source

pub fn with_bind(self, addr: SocketAddr) -> Self

Source

pub fn with_nonblocking(self, flag: bool) -> Self

Source

pub fn with_reuseaddr(self, flag: bool) -> Self

Source

pub fn with_nodelay(self, flag: bool) -> Self

Source

pub fn with_linger(self, dur: Duration) -> Self

Source

pub fn with_ttl(self, ttl: u32) -> Self

Source

pub fn with_hoplimit(self, hops: u32) -> Self

Source

pub fn with_keepalive(self, on: bool) -> Self

Source

pub fn with_read_timeout(self, timeout: Duration) -> Self

Source

pub fn with_write_timeout(self, timeout: Duration) -> Self

Source

pub fn with_bind_device(self, iface: impl Into<String>) -> Self

Trait Implementations§

Source§

impl Clone for TcpConfig

Source§

fn clone(&self) -> TcpConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TcpConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.