pub trait UdpSocket:
Debug
+ Send
+ Sync {
Show 18 methods
// Required methods
fn local_addr(&self) -> Result<SocketAddr>;
fn poll_send_to(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
receiver: &SocketAddr,
) -> Poll<Result<usize>>;
fn poll_recv_from(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<Result<(usize, SocketAddr)>>;
fn broadcast(&self) -> Result<bool>;
fn set_broadcast(&self, on: bool) -> Result<()>;
fn multicast_loop_v4(&self) -> Result<bool>;
fn set_multicast_loop_v4(&self, on: bool) -> Result<()>;
fn multicast_ttl_v4(&self) -> Result<u32>;
fn set_multicast_ttl_v4(&self, ttl: u32) -> Result<()>;
fn multicast_loop_v6(&self) -> Result<bool>;
fn set_multicast_loop_v6(&self, on: bool) -> Result<()>;
fn ttl(&self) -> Result<u32>;
fn set_ttl(&self, ttl: u32) -> Result<()>;
fn join_multicast_v4(
&self,
multiaddr: &Ipv4Addr,
interface: &Ipv4Addr,
) -> Result<()>;
fn join_multicast_v6(
&self,
multiaddr: &Ipv6Addr,
interface: u32,
) -> Result<()>;
fn leave_multicast_v4(
&self,
multiaddr: &Ipv4Addr,
interface: &Ipv4Addr,
) -> Result<()>;
fn leave_multicast_v6(
&self,
multiaddr: &Ipv6Addr,
interface: u32,
) -> Result<()>;
fn as_raw_fd(&self) -> RawFd;
}
Expand description
A UDP socket.
Required Methods§
Sourcefn local_addr(&self) -> Result<SocketAddr>
fn local_addr(&self) -> Result<SocketAddr>
Returns the local address that this listener is bound to.
This can be useful, for example, when binding to port 0 to figure out which port was actually bound.
Sourcefn poll_send_to(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
receiver: &SocketAddr,
) -> Poll<Result<usize>>
fn poll_send_to( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], receiver: &SocketAddr, ) -> Poll<Result<usize>>
Sends data on the IO interface to the specified target.
On success, returns the number of bytes written.
Sourcefn poll_recv_from(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<Result<(usize, SocketAddr)>>
fn poll_recv_from( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8], ) -> Poll<Result<(usize, SocketAddr)>>
Receives data from the IO interface.
On success, returns the number of bytes read and the target from whence the data came.
Sourcefn set_broadcast(&self, on: bool) -> Result<()>
fn set_broadcast(&self, on: bool) -> Result<()>
Sets the value of the SO_BROADCAST
option for this socket.
Sourcefn multicast_loop_v4(&self) -> Result<bool>
fn multicast_loop_v4(&self) -> Result<bool>
Gets the value of the IP_MULTICAST_LOOP
option for this socket.
Sourcefn set_multicast_loop_v4(&self, on: bool) -> Result<()>
fn set_multicast_loop_v4(&self, on: bool) -> Result<()>
Sets the value of the IP_MULTICAST_LOOP
option for this socket.
Sourcefn multicast_ttl_v4(&self) -> Result<u32>
fn multicast_ttl_v4(&self) -> Result<u32>
Gets the value of the IP_MULTICAST_TTL
option for this socket.
Sourcefn set_multicast_ttl_v4(&self, ttl: u32) -> Result<()>
fn set_multicast_ttl_v4(&self, ttl: u32) -> Result<()>
Sets the value of the IP_MULTICAST_TTL
option for this socket.
Sourcefn multicast_loop_v6(&self) -> Result<bool>
fn multicast_loop_v6(&self) -> Result<bool>
Gets the value of the IPV6_MULTICAST_LOOP
option for this socket.
Sourcefn set_multicast_loop_v6(&self, on: bool) -> Result<()>
fn set_multicast_loop_v6(&self, on: bool) -> Result<()>
Sets the value of the IPV6_MULTICAST_LOOP
option for this socket.
Sourcefn join_multicast_v4(
&self,
multiaddr: &Ipv4Addr,
interface: &Ipv4Addr,
) -> Result<()>
fn join_multicast_v4( &self, multiaddr: &Ipv4Addr, interface: &Ipv4Addr, ) -> Result<()>
Executes an operation of the IP_ADD_MEMBERSHIP
type.
Sourcefn join_multicast_v6(&self, multiaddr: &Ipv6Addr, interface: u32) -> Result<()>
fn join_multicast_v6(&self, multiaddr: &Ipv6Addr, interface: u32) -> Result<()>
Executes an operation of the IPV6_ADD_MEMBERSHIP
type.
Sourcefn leave_multicast_v4(
&self,
multiaddr: &Ipv4Addr,
interface: &Ipv4Addr,
) -> Result<()>
fn leave_multicast_v4( &self, multiaddr: &Ipv4Addr, interface: &Ipv4Addr, ) -> Result<()>
Executes an operation of the IP_DROP_MEMBERSHIP
type.