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: SocketFamilyThe socket family, either IPv4 or IPv6.
socket_type: TcpSocketTypeThe type of TCP socket, either STREAM or RAW.
bind_addr: Option<SocketAddr>Optional address to bind the socket to.
nonblocking: boolWhether 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
impl TcpConfig
pub fn with_bind(self, addr: SocketAddr) -> Self
pub fn with_nonblocking(self, flag: bool) -> Self
pub fn with_reuseaddr(self, flag: bool) -> Self
pub fn with_nodelay(self, flag: bool) -> Self
pub fn with_linger(self, dur: Duration) -> Self
pub fn with_ttl(self, ttl: u32) -> Self
pub fn with_hoplimit(self, hops: u32) -> Self
pub fn with_keepalive(self, on: bool) -> Self
pub fn with_read_timeout(self, timeout: Duration) -> Self
pub fn with_write_timeout(self, timeout: Duration) -> Self
pub fn with_bind_device(self, iface: impl Into<String>) -> Self
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TcpConfig
impl RefUnwindSafe for TcpConfig
impl Send for TcpConfig
impl Sync for TcpConfig
impl Unpin for TcpConfig
impl UnwindSafe for TcpConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more