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(
rx_buffer: SocketBuffer<'a, 'b>,
tx_buffer: SocketBuffer<'a, 'b>
) -> Socket<'a, 'b>
[src]
rx_buffer: SocketBuffer<'a, 'b>,
tx_buffer: SocketBuffer<'a, 'b>
) -> Socket<'a, 'b>
Create an UDP socket with the given buffers.
fn debug_id(&self) -> usize
[src]
Return the debug identifier.
fn set_debug_id(&mut self, id: usize)
[src]
Set the debug identifier.
The debug identifier is a number printed in socket trace messages. It could as well be used by the user code.
fn endpoint(&self) -> IpEndpoint
[src]
Return the bound endpoint.
fn bind<T: Into<IpEndpoint>>(&mut self, endpoint: T) -> Result<()>
[src]
Bind the socket to the given endpoint.
This function returns Err(Error::Illegal)
if the socket was open
(see is_open), and Err(Error::Unaddressable)
if the port in the given endpoint is zero.
fn is_open(&self) -> bool
[src]
Check whether the socket is open.
fn can_send(&self) -> bool
[src]
Check whether the transmit buffer is full.
fn can_recv(&self) -> bool
[src]
Check whether the receive buffer is not empty.
fn send(&mut self, size: usize, endpoint: IpEndpoint) -> Result<&mut [u8]>
[src]
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 transmit buffer is full,
Err(Error::Truncated)
if the requested size is larger than the packet buffer
size, and Err(Error::Unaddressable)
if local or remote port, or remote address,
are unspecified.
fn send_slice(&mut self, data: &[u8], endpoint: IpEndpoint) -> Result<()>
[src]
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<(&[u8], IpEndpoint)>
[src]
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<(usize, IpEndpoint)>
[src]
Dequeue a packet received from a remote endpoint, and return the endpoint as well as copy the payload into the given slice.
See also recv.