Skip to main content

udp_connect

Function udp_connect 

Source
pub fn udp_connect(backend: SocketAddr) -> Result<UdpSocket, ServerBindError>
Expand description

Create a non-blocking connected per-flow upstream UDP socket toward backend.

The socket is bound to an ephemeral local port (family matched to the backend) and connect-ed to the backend address. A connected UDP socket “only receives from the connected address” (connect(2)), so its fd is the symmetric-NAT return-demux key for one flow: the shell registers upstream_token -> FlowId and feeds anything that arrives on it back into the manager as a BackendDatagram. send (not send_to) is then used for the forward path. Errors (EMFILE/ENFILE/connect refusal) bubble up so the caller can shed the flow rather than panic.