SocketConfig

Struct SocketConfig 

Source
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: usize

Receive buffer size in bytes (SO_RCVBUF). Larger values reduce packet drops under load. Default: 4MB

§send_buffer_size: usize

Send buffer size in bytes (SO_SNDBUF). Larger values allow more in-flight packets. Default: 4MB

§busy_poll_us: u32

Busy 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: u8

IP 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: u32

Socket priority (SO_PRIORITY). Higher values = higher priority (0-6). Default: 6 (highest)

§reuse_addr: bool

Enable SO_REUSEADDR. Default: true

§reuse_port: bool

Enable SO_REUSEPORT (Linux 3.9+). Allows multiple sockets on same port for load balancing. Default: false

§tcp_nodelay: bool

Disable Nagle’s algorithm for TCP (TCP_NODELAY). Already disabled by default in most cases. Default: true

Implementations§

Source§

impl SocketConfig

Source

pub fn low_latency() -> Self

Configuration optimized for minimal latency. Uses aggressive CPU polling.

Source

pub fn high_throughput() -> Self

Configuration optimized for high throughput. Larger buffers, less CPU polling.

Source

pub fn apply_udp(&self, socket: &UdpSocket) -> Result<()>

Apply configuration to a UDP socket.

Trait Implementations§

Source§

impl Clone for SocketConfig

Source§

fn clone(&self) -> SocketConfig

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 SocketConfig

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for SocketConfig

Source§

fn default() -> Self

Returns the “default value” for a type. 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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V