pub struct UdpSocket { /* private fields */ }
Available on crate feature
net
only.Expand description
A UDP socket.
Implementations§
source§impl UdpSocket
impl UdpSocket
sourcepub fn bind(addr: SocketAddr) -> Result<Self>
pub fn bind(addr: SocketAddr) -> Result<Self>
Creates a UDP socket from the given address.
sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Returns the socket address that this socket was created from.
sourcepub fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>
pub fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>
Receives a message on the socket.
sourcepub fn send_to(&self, buf: &[u8], addr: SocketAddr) -> Result<usize>
pub fn send_to(&self, buf: &[u8], addr: SocketAddr) -> Result<usize>
Sends data on the socket to the given address.
sourcepub fn connect(&mut self, addr: SocketAddr) -> Result<()>
pub fn connect(&mut self, addr: SocketAddr) -> Result<()>
Connects this UDP socket to a remote address.
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