pub struct UdpSocket { /* private fields */ }Expand description
Native async UDP socket
Implementations§
Source§impl UdpSocket
impl UdpSocket
Sourcepub async fn bind_with_config(addr: &str, config: UdpConfig) -> Result<Self>
pub async fn bind_with_config(addr: &str, config: UdpConfig) -> Result<Self>
Bind UDP socket with custom configuration
Sourcepub async fn send_to(&self, buf: &[u8], target: SocketAddr) -> Result<usize>
pub async fn send_to(&self, buf: &[u8], target: SocketAddr) -> Result<usize>
Send data to a specific address
Sourcepub async fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>
pub async fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>
Receive data from any address
Sourcepub fn stats(&self) -> UdpSocketStats
pub fn stats(&self) -> UdpSocketStats
Get UDP socket statistics
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Return the local socket address this UDP socket is bound to.
Auto Trait Implementations§
impl Freeze for UdpSocket
impl RefUnwindSafe for UdpSocket
impl Send for UdpSocket
impl Sync for UdpSocket
impl Unpin for UdpSocket
impl UnsafeUnpin 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