pub trait UdpSas: Sized {
    fn bind_sas<A: ToSocketAddrs>(addr: A) -> Result<Self>;
    fn send_sas(
        &self,
        buf: &[u8],
        target: &SocketAddr,
        local: &IpAddr
    ) -> Result<usize>; fn recv_sas(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr, IpAddr)>; }
Expand description

An extension trait to support source address selection in std::net::UdpSocket

See module level documentation for more details.

Required Methods

Creates a UDP socket from the given address.

The address type can be any implementor of ToSocketAddrs trait. See its documentation for concrete examples.

The new socket is configured with the IP_PKTINFO or IPV6_RECVPKTINFO option enabled.

Examples
use std::net::UdpSocket;
use udp_sas::UdpSas;

let socket = UdpSocket::bind_sas("127.0.0.1:34254").expect("couldn't bind to address");

Sends a datagram to the given target address and use the local address as its source.

On success, returns the number of bytes written.

Receive a datagram

On success, returns a tuple (nb, source, local) containing the number of bytes read, the source socket address (peer address), and the destination ip address (local address).

Implementations on Foreign Types

Implementors