pub struct UdpConfig {Show 17 fields
pub socket_family: SocketFamily,
pub socket_type: UdpSocketType,
pub bind_addr: Option<SocketAddr>,
pub reuseaddr: Option<bool>,
pub reuseport: Option<bool>,
pub broadcast: Option<bool>,
pub ttl: Option<u32>,
pub hoplimit: Option<u32>,
pub read_timeout: Option<Duration>,
pub write_timeout: Option<Duration>,
pub recv_buffer_size: Option<usize>,
pub send_buffer_size: Option<usize>,
pub tos: Option<u32>,
pub tclass_v6: Option<u32>,
pub recv_pktinfo: Option<bool>,
pub only_v6: Option<bool>,
pub bind_device: Option<String>,
}Expand description
Configuration options for a UDP socket.
Fields§
§socket_family: SocketFamilyThe socket family.
socket_type: UdpSocketTypeThe socket type (DGRAM or RAW).
bind_addr: Option<SocketAddr>Address to bind. If None, the operating system chooses the address.
reuseaddr: Option<bool>Enable address reuse (SO_REUSEADDR).
reuseport: Option<bool>Whether to allow port reuse (SO_REUSEPORT) where supported.
broadcast: Option<bool>Allow broadcast (SO_BROADCAST).
ttl: Option<u32>Time to live value.
hoplimit: Option<u32>Hop limit value.
read_timeout: Option<Duration>Read timeout for the socket.
write_timeout: Option<Duration>Write timeout for the socket.
recv_buffer_size: Option<usize>Optional receive buffer size in bytes.
send_buffer_size: Option<usize>Optional send buffer size in bytes.
tos: Option<u32>Optional IPv4 TOS / DSCP field value.
tclass_v6: Option<u32>Optional IPv6 traffic class value (IPV6_TCLASS) where supported.
recv_pktinfo: Option<bool>Enable receiving packet info ancillary data (IP_PKTINFO / IPV6_RECVPKTINFO) where supported.
only_v6: Option<bool>Whether to force IPv6-only behavior on dual-stack sockets.
bind_device: Option<String>Bind to a specific interface (Linux only).
Implementations§
Source§impl UdpConfig
impl UdpConfig
Sourcepub fn new_with_family(socket_family: SocketFamily) -> Self
pub fn new_with_family(socket_family: SocketFamily) -> Self
Create a new UDP configuration for a specific socket family.
Sourcepub fn with_socket_family(self, socket_family: SocketFamily) -> Self
pub fn with_socket_family(self, socket_family: SocketFamily) -> Self
Set the socket family.
Sourcepub fn with_bind_addr(self, addr: SocketAddr) -> Self
pub fn with_bind_addr(self, addr: SocketAddr) -> Self
Set the bind address.
Sourcepub fn with_bind(self, addr: SocketAddr) -> Self
pub fn with_bind(self, addr: SocketAddr) -> Self
Set the bind address.
Sourcepub fn with_reuseaddr(self, on: bool) -> Self
pub fn with_reuseaddr(self, on: bool) -> Self
Enable address reuse.
Sourcepub fn with_reuseport(self, on: bool) -> Self
pub fn with_reuseport(self, on: bool) -> Self
Enable port reuse.
Sourcepub fn with_broadcast(self, on: bool) -> Self
pub fn with_broadcast(self, on: bool) -> Self
Allow broadcast.
Sourcepub fn with_hoplimit(self, hops: u32) -> Self
pub fn with_hoplimit(self, hops: u32) -> Self
Set the hop limit value.
Sourcepub fn with_hop_limit(self, hops: u32) -> Self
pub fn with_hop_limit(self, hops: u32) -> Self
Set the hop limit value.
Sourcepub fn with_read_timeout(self, timeout: Duration) -> Self
pub fn with_read_timeout(self, timeout: Duration) -> Self
Set the read timeout.
Sourcepub fn with_write_timeout(self, timeout: Duration) -> Self
pub fn with_write_timeout(self, timeout: Duration) -> Self
Set the write timeout.
Sourcepub fn with_recv_buffer_size(self, size: usize) -> Self
pub fn with_recv_buffer_size(self, size: usize) -> Self
Set the receive buffer size.
Sourcepub fn with_send_buffer_size(self, size: usize) -> Self
pub fn with_send_buffer_size(self, size: usize) -> Self
Set the send buffer size.
Sourcepub fn with_tclass_v6(self, tclass: u32) -> Self
pub fn with_tclass_v6(self, tclass: u32) -> Self
Set the IPv6 traffic class value.
Sourcepub fn with_recv_pktinfo(self, on: bool) -> Self
pub fn with_recv_pktinfo(self, on: bool) -> Self
Enable packet-info ancillary data receiving.
Sourcepub fn with_only_v6(self, only_v6: bool) -> Self
pub fn with_only_v6(self, only_v6: bool) -> Self
Set whether the socket is IPv6 only.
Sourcepub fn with_bind_device(self, iface: impl Into<String>) -> Self
pub fn with_bind_device(self, iface: impl Into<String>) -> Self
Bind to a specific interface (Linux only).