pub trait Socket {
    type Error: Debug;
    fn connect<A: ToSocketAddrs>(&mut self, addr: A) -> Result<(), Self::Error>;
fn send(&self, msg: &[u8]) -> Result<(), Self::Error>;
fn recv(
        &self,
        buffer: &mut [u8]
    ) -> Result<(usize, SocketAddr), Self::Error>; fn poll(
        &self
    ) -> Result<Option<(ArrayVec<[u8; 1152]>, SocketAddr)>, Self::Error> { ... } }
Expand description

A CoAP network socket

This mirrors the Udp socket traits in embedded-nal, but allows us to implement them for foreign types (like std::net::UdpSocket).

One notable difference is that connecting is expected to modify the internal state of a Socket, not yield a connected socket type (like std::net::UdpSocket::connect).

Associated Types

The error yielded by socket operations

Required methods

Connect as a client to some remote host

Send a message to the connected host

Pull a buffered datagram from the socket, along with the address to the sender.

Provided methods

Poll the socket for a datagram

Implementations on Foreign Types

Implementors