pub struct UdpSocket { /* private fields */ }Expand description
Async UDP datagram socket.
Implementations§
Source§impl UdpSocket
impl UdpSocket
Sourcepub fn bind(addr: SocketAddr) -> Result<Self>
pub fn bind(addr: SocketAddr) -> Result<Self>
Bind a UDP socket to addr.
Creates a SOCK_DGRAM socket, binds to addr, sets non-blocking, and
registers with the reactor for both read and write readiness.
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Return the local address the socket is bound to.
Sourcepub fn send_to<'a>(
&'a self,
buf: &'a [u8],
target: SocketAddr,
) -> SendToFuture<'a> ⓘ
pub fn send_to<'a>( &'a self, buf: &'a [u8], target: SocketAddr, ) -> SendToFuture<'a> ⓘ
Return a future that sends buf to target and resolves to the number
of bytes sent.
Sourcepub fn recv_from<'a>(&'a self, buf: &'a mut [u8]) -> RecvFromFuture<'a> ⓘ
pub fn recv_from<'a>(&'a self, buf: &'a mut [u8]) -> RecvFromFuture<'a> ⓘ
Return a future that receives a datagram into buf and resolves to
(bytes_received, sender_addr).
Trait Implementations§
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