pub struct SocketConfig {
pub recv_buffer_size: usize,
pub send_buffer_size: usize,
pub busy_poll_us: u32,
pub ip_tos: u8,
pub priority: u32,
pub reuse_addr: bool,
pub reuse_port: bool,
pub tcp_nodelay: bool,
}Expand description
Socket tuning configuration for low-latency networking.
Fields§
§recv_buffer_size: usizeReceive buffer size in bytes (SO_RCVBUF). Larger values reduce packet drops under load. Default: 4MB
send_buffer_size: usizeSend buffer size in bytes (SO_SNDBUF). Larger values allow more in-flight packets. Default: 4MB
busy_poll_us: u32Busy poll timeout in microseconds (SO_BUSY_POLL). Set to 0 to disable. Requires CAP_NET_ADMIN. Trades CPU for lower latency. Default: 50µs
ip_tos: u8IP Type of Service / DSCP value (IP_TOS). Common values:
- 0x00: Best effort
- 0x10: Low delay (DSCP CS1)
- 0xB8: Expedited forwarding (DSCP EF, 46 << 2) Default: 0xB8 (EF - Expedited Forwarding for real-time)
priority: u32Socket priority (SO_PRIORITY). Higher values = higher priority (0-6). Default: 6 (highest)
reuse_addr: boolEnable SO_REUSEADDR. Default: true
reuse_port: boolEnable SO_REUSEPORT (Linux 3.9+). Allows multiple sockets on same port for load balancing. Default: false
tcp_nodelay: boolDisable Nagle’s algorithm for TCP (TCP_NODELAY). Already disabled by default in most cases. Default: true
Implementations§
Source§impl SocketConfig
impl SocketConfig
Sourcepub fn low_latency() -> Self
pub fn low_latency() -> Self
Configuration optimized for minimal latency. Uses aggressive CPU polling.
Sourcepub fn high_throughput() -> Self
pub fn high_throughput() -> Self
Configuration optimized for high throughput. Larger buffers, less CPU polling.
Trait Implementations§
Source§impl Clone for SocketConfig
impl Clone for SocketConfig
Source§fn clone(&self) -> SocketConfig
fn clone(&self) -> SocketConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more