pub struct UdpSocket<'a> { /* private fields */ }Expand description
An UDP socket.
Implementations§
Source§impl<'a> UdpSocket<'a>
impl<'a> UdpSocket<'a>
Sourcepub fn new<D: Driver>(
stack: &'a Stack<D>,
rx_meta: &'a mut [PacketMetadata],
rx_buffer: &'a mut [u8],
tx_meta: &'a mut [PacketMetadata],
tx_buffer: &'a mut [u8],
) -> Self
pub fn new<D: Driver>( stack: &'a Stack<D>, rx_meta: &'a mut [PacketMetadata], rx_buffer: &'a mut [u8], tx_meta: &'a mut [PacketMetadata], tx_buffer: &'a mut [u8], ) -> Self
Create a new UDP socket using the provided stack and buffers.
Sourcepub fn bind<T>(&mut self, endpoint: T) -> Result<(), BindError>where
T: Into<IpListenEndpoint>,
pub fn bind<T>(&mut self, endpoint: T) -> Result<(), BindError>where
T: Into<IpListenEndpoint>,
Bind the socket to a local endpoint.
Sourcepub async fn recv_from(
&self,
buf: &mut [u8],
) -> Result<(usize, IpEndpoint), Error>
pub async fn recv_from( &self, buf: &mut [u8], ) -> Result<(usize, IpEndpoint), Error>
Receive a datagram.
This method will wait until a datagram is received.
Returns the number of bytes received and the remote endpoint.
Sourcepub async fn send_to<T>(
&self,
buf: &[u8],
remote_endpoint: T,
) -> Result<(), Error>where
T: Into<IpEndpoint>,
pub async fn send_to<T>(
&self,
buf: &[u8],
remote_endpoint: T,
) -> Result<(), Error>where
T: Into<IpEndpoint>,
Send a datagram to the specified remote endpoint.
Sourcepub fn endpoint(&self) -> IpListenEndpoint
pub fn endpoint(&self) -> IpListenEndpoint
Returns the local endpoint of the socket.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for UdpSocket<'a>
impl<'a> !RefUnwindSafe for UdpSocket<'a>
impl<'a> !Send for UdpSocket<'a>
impl<'a> !Sync for UdpSocket<'a>
impl<'a> Unpin for UdpSocket<'a>
impl<'a> !UnwindSafe for UdpSocket<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more