Struct unix_udp_sock::sync::UdpSocket
source · pub struct UdpSocket { /* private fields */ }
Implementations§
source§impl UdpSocket
impl UdpSocket
sourcepub fn from_std(socket: UdpSocket) -> Result<Self>
pub fn from_std(socket: UdpSocket) -> Result<Self>
Creates a new UDP socket from a previously created std::net::UdpSocket
sourcepub fn bind<A: ToSocketAddrs>(addr: A) -> Result<Self>
pub fn bind<A: ToSocketAddrs>(addr: A) -> Result<Self>
create a new UDP socket and attempt to bind to addr
sourcepub fn set_nonblocking(&self, nonblocking: bool) -> Result<()>
pub fn set_nonblocking(&self, nonblocking: bool) -> Result<()>
sets nonblocking mode
sourcepub fn set_broadcast(&self, broadcast: bool) -> Result<()>
pub fn set_broadcast(&self, broadcast: bool) -> Result<()>
sets the value of SO_BROADCAST for this socket
pub fn connect<A: ToSocketAddrs>(&self, addrs: A) -> Result<()>
pub fn join_multicast_v4( &self, multiaddr: Ipv4Addr, interface: Ipv4Addr, ) -> Result<()>
pub fn join_multicast_v6( &self, multiaddr: &Ipv6Addr, interface: u32, ) -> Result<()>
pub fn leave_multicast_v4( &self, multiaddr: Ipv4Addr, interface: Ipv4Addr, ) -> Result<()>
pub fn leave_multicast_v6( &self, multiaddr: &Ipv6Addr, interface: u32, ) -> Result<()>
pub fn set_multicast_loop_v4(&self, on: bool) -> Result<()>
pub fn set_multicast_loop_v6(&self, on: bool) -> Result<()>
sourcepub fn send_to(&self, buf: &[u8], target: SocketAddr) -> Result<usize>
pub fn send_to(&self, buf: &[u8], target: SocketAddr) -> Result<usize>
Sends data on the socket to the given address. On success, returns the number of bytes written.
calls underlying tokio send_to
sourcepub fn send(&self, buf: &[u8]) -> Result<usize>
pub fn send(&self, buf: &[u8]) -> Result<usize>
Sends data on the socket to the remote address that the socket is connected to.
See tokio send
sourcepub fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>
pub fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>
Receives a single datagram message on the socket. On success, returns the number of bytes read and the origin.
See tokio recv_from
sourcepub fn recv(&self, buf: &mut [u8]) -> Result<usize>
pub fn recv(&self, buf: &mut [u8]) -> Result<usize>
Receives a single datagram message on the socket from the remote address to which it is connected. On success, returns the number of bytes read.
See tokio recv
sourcepub fn send_mmsg<B: AsPtr<u8>>(
&mut self,
state: &UdpState,
transmits: &[Transmit<B>],
) -> Result<usize, Error>
pub fn send_mmsg<B: AsPtr<u8>>( &mut self, state: &UdpState, transmits: &[Transmit<B>], ) -> Result<usize, Error>
Calls syscall sendmmsg
. With a given state
configured GSO and
transmits
with information on the data and metadata about outgoing packets.
sourcepub fn send_msg<B: AsPtr<u8>>(
&self,
state: &UdpState,
transmits: Transmit<B>,
) -> Result<usize>
pub fn send_msg<B: AsPtr<u8>>( &self, state: &UdpState, transmits: Transmit<B>, ) -> Result<usize>
Calls syscall sendmsg
. With a given state
configured GSO and
transmit
with information on the data and metadata about outgoing packet.
sourcepub fn recv_mmsg(
&self,
bufs: &mut [IoSliceMut<'_>],
meta: &mut [RecvMeta],
) -> Result<usize>
pub fn recv_mmsg( &self, bufs: &mut [IoSliceMut<'_>], meta: &mut [RecvMeta], ) -> Result<usize>
async version of recvmmsg
sourcepub fn recv_msg(&self, buf: &mut [u8]) -> Result<RecvMeta>
pub fn recv_msg(&self, buf: &mut [u8]) -> Result<RecvMeta>
recv_msg
is similar to recv_from
but returns extra information
about the packet in RecvMeta
.
sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Returns local address this socket is bound to.