Skip to main content

bind_udp_socket_with_connect

Function bind_udp_socket_with_connect 

pub async fn bind_udp_socket_with_connect(
    address: impl Into<HostWithPort>,
    extensions: Option<&Extensions>,
) -> Result<UdpSocket, Box<dyn Error + Sync + Send>>
Available on crate features std and udp only.
Expand description

Bind a UdpSocket to the local interface and connect to the given IP host and port.

The host must be an IP address. Domain-name resolution belongs in rama-dns connector middleware.

This helper respects IP connect preferences (e.g. Ipv6 addresses won’t be allowed if running in Ipv4 only modes). IPv4-mapped IPv6 addresses (::ffff:a.b.c.d) are canonicalized to the embedded IPv4 address, as they identify IPv4 wire traffic.

Connecting a UDP socket configures its default remote peer and restricts incoming datagrams to that peer. It does not perform a handshake or guarantee reachability.