Skip to main content

bind_sockets

Function bind_sockets 

Source
pub fn bind_sockets(port: u16, want_ipv6: bool) -> Result<Vec<UdpSocket>>
Expand description

Bind the UDP sockets QUIC will use: IPv4 on 0.0.0.0:port and, when want_ipv6, IPv6 on [::]:port with IPV6_V6ONLY so the two do not collide. Both are non-blocking and SO_REUSEADDR.

These are bound here, up front, because STUN has to run on the very socket that later receives QUIC. Binding a temporary socket and letting the QUIC stack rebind the port makes the advertised reflexive address a guess — on port-preserving home routers it usually held, on strict ones it silently did not. Same socket, never rebound, no guess.

IPv6 failure is not fatal: the agent continues IPv4-only.