pub struct UdpSocket { /* private fields */ }
Expand description
A socket that sends and receives UDP messages
Implementations§
source§impl UdpSocket
impl UdpSocket
sourcepub async fn bind(addr: impl ToSocketAddrs) -> Result<Self, Error>
pub async fn bind(addr: impl ToSocketAddrs) -> Result<Self, Error>
Bind a new socket to the given address
sourcepub async fn bind_with_cancellation(
addr: impl ToSocketAddrs,
token: &CancellationToken
) -> Result<Self, Error>
pub async fn bind_with_cancellation( addr: impl ToSocketAddrs, token: &CancellationToken ) -> Result<Self, Error>
Bind a new socket to the given address
sourcepub async fn split_owned(
self
) -> Result<(OwnedUdpReceiveSocket, OwnedUdpSendSocket), Error>
pub async fn split_owned( self ) -> Result<(OwnedUdpReceiveSocket, OwnedUdpSendSocket), Error>
Split the socket into an owned read and write half
sourcepub fn split(&self) -> (UdpReceiveSocket<'_>, UdpSendSocket<'_>)
pub fn split(&self) -> (UdpReceiveSocket<'_>, UdpSendSocket<'_>)
Split the socket into a borrowed read and write half
sourcepub async fn receive_from<'buf>(
&self,
buf: &'buf mut [u8]
) -> Result<(&'buf mut [u8], SocketAddr), Error>
pub async fn receive_from<'buf>( &self, buf: &'buf mut [u8] ) -> Result<(&'buf mut [u8], SocketAddr), Error>
Try to fill the given buffer with received data. The part of the buffer that was filled is returned together with the address of the source of the message.
sourcepub async fn receive_from_with_cancellation<'buf>(
&self,
buf: &'buf mut [u8],
token: &CancellationToken
) -> Result<(&'buf mut [u8], SocketAddr), Error>
pub async fn receive_from_with_cancellation<'buf>( &self, buf: &'buf mut [u8], token: &CancellationToken ) -> Result<(&'buf mut [u8], SocketAddr), Error>
Try to fill the given buffer with received data. The part of the buffer that was filled is returned together with the address of the source of the message.
sourcepub async fn send_to(&self, buf: &[u8], addr: SocketAddr) -> Result<(), Error>
pub async fn send_to(&self, buf: &[u8], addr: SocketAddr) -> Result<(), Error>
Send the given buffer to the given address
sourcepub async fn send_to_with_cancellation(
&self,
buf: &[u8],
addr: SocketAddr,
token: &CancellationToken
) -> Result<(), Error>
pub async fn send_to_with_cancellation( &self, buf: &[u8], addr: SocketAddr, token: &CancellationToken ) -> Result<(), Error>
Send the given buffer to the given address
sourcepub async fn deactivate(self) -> Result<(), Error>
pub async fn deactivate(self) -> Result<(), Error>
Deactivates the socket and the LTE link. A normal drop will do the same thing, but blocking.
Auto Trait Implementations§
impl RefUnwindSafe for UdpSocket
impl Send for UdpSocket
impl Sync for UdpSocket
impl Unpin for UdpSocket
impl UnwindSafe for UdpSocket
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