Struct smoltcp::socket::UdpSocket
[−]
[src]
pub struct UdpSocket<'a, 'b: 'a> { /* fields omitted */ }
An User Datagram Protocol socket.
An UDP socket is bound to a specific endpoint, and owns transmit and receive packet buffers.
Methods
impl<'a, 'b> UdpSocket<'a, 'b>
[src]
fn new(endpoint: IpEndpoint,
rx_buffer: SocketBuffer<'a, 'b>,
tx_buffer: SocketBuffer<'a, 'b>)
-> Socket<'a, 'b>
rx_buffer: SocketBuffer<'a, 'b>,
tx_buffer: SocketBuffer<'a, 'b>)
-> Socket<'a, 'b>
Create an UDP socket with the given buffers.
fn send(&mut self,
endpoint: IpEndpoint,
size: usize)
-> Result<&mut [u8], Error>
endpoint: IpEndpoint,
size: usize)
-> Result<&mut [u8], Error>
Enqueue a packet to be sent to a given remote endpoint, and return a pointer to its payload.
This function returns Err(Error::Exhausted)
if the size is greater than what
the transmit buffer can accomodate.
fn send_slice(&mut self, endpoint: IpEndpoint, data: &[u8]) -> Result<(), Error>
Enqueue a packet to be sent to a given remote endpoint, and fill it from a slice.
See also send.
fn recv(&mut self) -> Result<(IpEndpoint, &[u8]), Error>
Dequeue a packet received from a remote endpoint, and return the endpoint as well as a pointer to the payload.
This function returns Err(Error::Exhausted)
if the receive buffer is empty.
fn recv_slice(&mut self, data: &mut [u8]) -> Result<(IpEndpoint, usize), Error>
Dequeue a packet received from a remote endpoint, and return the endpoint as well as copy the payload into the given slice.
This function returns Err(Error::Exhausted)
if the received packet has payload
larger than the provided slice. See also recv.
fn process(&mut self, ip_repr: &IpRepr, payload: &[u8]) -> Result<(), Error>
See Socket::process.
fn dispatch<F, R>(&mut self, emit: &mut F) -> Result<R, Error> where F: FnMut(&IpRepr, &IpPayload) -> Result<R, Error>
See Socket::dispatch.