Trait Socket

Source
pub trait Socket: Debug {
    // Required methods
    fn new<T: ToSocketAddrs>(_: T, _: usize) -> Result<Self, Error>
       where Self: Sized;
    fn try_recv(&mut self) -> Result<(SocketAddr, Vec<u8>), TryRecvError>;
    fn send_to(&mut self, data: &[u8], addr: SocketAddr) -> Result<usize, Error>;
    fn local_addr(&self) -> Result<SocketAddr, Error>;
}
Expand description

Trait describing a non-blocking low latency socket.

Required Methods§

Source

fn new<T: ToSocketAddrs>(_: T, _: usize) -> Result<Self, Error>
where Self: Sized,

Method that tries to bind a new socket at the specified address.

Source

fn try_recv(&mut self) -> Result<(SocketAddr, Vec<u8>), TryRecvError>

Method that attempts to return a incoming packet on this socket without blocking.

Source

fn send_to(&mut self, data: &[u8], addr: SocketAddr) -> Result<usize, Error>

Method sending data on the socket to the given address. On success, returns the number of bytes written.

Source

fn local_addr(&self) -> Result<SocketAddr, Error>

Method returning the address of the actual, underlying socket.

Implementors§