pub struct SocketConfig {
pub bind_addr: Option<SocketAddr>,
pub ttl: Option<u32>,
pub ipv4_only: bool,
pub ipv6_only: bool,
pub recv_timeout: Option<Duration>,
}Expand description
Local UDP socket options used by ClientConfig.
These settings affect how the client binds, resolves, and receives from the socket. They do not change the IRTT protocol parameters negotiated with the server.
§Example
Bind to a chosen local endpoint and set the outgoing IPv4 TTL:
use std::net::{Ipv4Addr, SocketAddr};
use irtt_client::{ClientConfig, SocketConfig};
let config = ClientConfig {
socket_config: SocketConfig {
bind_addr: Some(SocketAddr::from((Ipv4Addr::UNSPECIFIED, 0))),
ttl: Some(32),
ipv4_only: true,
..SocketConfig::default()
},
..ClientConfig::default()
};
assert_eq!(config.socket_config.ttl, Some(32));
assert!(config.socket_config.ipv4_only);Fields§
§bind_addr: Option<SocketAddr>Local address to bind before connecting the UDP socket.
None binds to an unspecified address with an ephemeral port matching
the selected remote address family.
ttl: Option<u32>Optional IPv4 TTL or IPv6 hop limit applied to sent packets.
None leaves the platform default unchanged. Values must fit in the
platform socket option range; MAX_TTL is the public configuration
bound used by this crate.
ipv4_only: boolRestrict name resolution to IPv4 addresses.
ipv6_only: boolRestrict name resolution to IPv6 addresses and set IPV6_V6ONLY for IPv6 sockets.
recv_timeout: Option<Duration>Socket read timeout used after the session is open.
None leaves reads blocking for APIs that perform a single receive.
Managed sessions may replace None or long timeouts with a short
timeout so cooperative cancellation can be observed promptly.