pub struct UdpSocket { /* private fields */ }
Expand description
Non-blocking abstraction over a UDP socket.
Trait Implementations§
Source§impl Socket for UdpSocket
impl Socket for UdpSocket
Source§fn new<T: ToSocketAddrs>(
address: T,
max_packet_size: usize,
) -> Result<Self, Error>
fn new<T: ToSocketAddrs>( address: T, max_packet_size: usize, ) -> Result<Self, Error>
Tries to create a new UDP socket by binding to the specified address.
Source§fn try_recv(&mut self) -> Result<(SocketAddr, Vec<u8>), TryRecvError>
fn try_recv(&mut self) -> Result<(SocketAddr, Vec<u8>), TryRecvError>
Attempts to return a incoming packet on this socket without blocking.
Source§fn send_to(&mut self, data: &[u8], addr: SocketAddr) -> Result<usize, Error>
fn send_to(&mut self, data: &[u8], addr: SocketAddr) -> Result<usize, Error>
Send data on the socket to the given address. On success, returns the number of bytes written.
Source§fn local_addr(&self) -> Result<SocketAddr, Error>
fn local_addr(&self) -> Result<SocketAddr, Error>
Returns the socket address of the underlying net::UdpSocket
.
Auto Trait Implementations§
impl Freeze for UdpSocket
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