pub struct UdpSocket { /* private fields */ }Expand description
A UDP socket.
Implementations§
Source§impl UdpSocket
impl UdpSocket
Sourcepub fn send_to_blocking(
&self,
endpoint: SocketAddr,
data: &[u8],
) -> Result<(), Error>
pub fn send_to_blocking( &self, endpoint: SocketAddr, data: &[u8], ) -> Result<(), Error>
Send a packet to the given endpoint with the provided data.
Sourcepub async fn send_to(
&self,
endpoint: SocketAddr,
data: &[u8],
) -> Result<(), Error>
pub async fn send_to( &self, endpoint: SocketAddr, data: &[u8], ) -> Result<(), Error>
Send a packet to the given endpoint with the provided data.
Sourcepub fn send_to_from_blocking(
&self,
endpoint: SocketAddr,
local: IpAddr,
data: &[u8],
) -> Result<(), Error>
pub fn send_to_from_blocking( &self, endpoint: SocketAddr, local: IpAddr, data: &[u8], ) -> Result<(), Error>
Send a packet to endpoint, spoofing the source address as local.
Used by a forwarder so reply datagrams appear to originate from the original destination the peer expected.
Sourcepub async fn send_to_from(
&self,
endpoint: SocketAddr,
local: IpAddr,
data: &[u8],
) -> Result<(), Error>
pub async fn send_to_from( &self, endpoint: SocketAddr, local: IpAddr, data: &[u8], ) -> Result<(), Error>
Send a packet to endpoint, spoofing the source address as local.
Used by a forwarder so reply datagrams appear to originate from the original destination the peer expected.
Sourcepub fn recv_from_blocking(
&self,
buf: &mut [u8],
) -> Result<(SocketAddr, usize), Error>
pub fn recv_from_blocking( &self, buf: &mut [u8], ) -> Result<(SocketAddr, usize), Error>
Receive a packet into the given buffer.
Sourcepub fn recv_from_bytes_blocking(&self) -> Result<(SocketAddr, Bytes), Error>
pub fn recv_from_bytes_blocking(&self) -> Result<(SocketAddr, Bytes), Error>
Receive a packet bytes buffer.
Sourcepub async fn recv_from(
&self,
buf: &mut [u8],
) -> Result<(SocketAddr, usize), Error>
pub async fn recv_from( &self, buf: &mut [u8], ) -> Result<(SocketAddr, usize), Error>
Receive a packet into the given buffer.
Sourcepub async fn recv_from_bytes(&self) -> Result<(SocketAddr, Bytes), Error>
pub async fn recv_from_bytes(&self) -> Result<(SocketAddr, Bytes), Error>
Asynchronously receive a packet bytes buffer.
Sourcepub fn recv_from_with_dst_bytes_blocking(
&self,
) -> Result<(SocketAddr, SocketAddr, Bytes), Error>
pub fn recv_from_with_dst_bytes_blocking( &self, ) -> Result<(SocketAddr, SocketAddr, Bytes), Error>
Receive a packet, also reporting the local (destination) address it was sent to.
Under any-IP acceptance the local address is the original packet destination – a
forwarder needs it to know which real socket to relay through. Returns
(remote, local, payload).
Sourcepub async fn recv_from_with_dst_bytes(
&self,
) -> Result<(SocketAddr, SocketAddr, Bytes), Error>
pub async fn recv_from_with_dst_bytes( &self, ) -> Result<(SocketAddr, SocketAddr, Bytes), Error>
Receive a packet, also reporting the local (destination) address it was sent to.
Under any-IP acceptance the local address is the original packet destination – a
forwarder needs it to know which real socket to relay through. Returns
(remote, local, payload).
Sourcepub const fn local_addr(&self) -> SocketAddr
pub const fn local_addr(&self) -> SocketAddr
Report the local endpoint to which this socket is bound.