pub struct IcmpSocket { /* private fields */ }Expand description
Asynchronous, non-blocking ICMP raw socket.
Wraps a socket2::Socket in tokio::io::unix::AsyncFd so that send
and receive operations integrate with the Tokio runtime. Supports both
ICMPv4 and ICMPv6; the protocol is selected by the address family of the
bind address.
Creating an IcmpSocket requires permission to open raw sockets
(e.g. CAP_NET_RAW on Linux, or running as root).
Implementations§
Source§impl IcmpSocket
impl IcmpSocket
Sourcepub async fn bind<A: ToIpAddr>(addr: A) -> Result<IcmpSocket>
pub async fn bind<A: ToIpAddr>(addr: A) -> Result<IcmpSocket>
Create a new ICMP raw socket bound to addr.
The address family of addr (after resolution) determines whether an
ICMPv4 or ICMPv6 socket is created. The socket is placed in
non-blocking mode and registered with the current Tokio runtime.
Sourcepub async fn connect<A: ToIpAddr>(&self, addr: A) -> Result<()>
pub async fn connect<A: ToIpAddr>(&self, addr: A) -> Result<()>
Connect this socket to addr so that subsequent send/recv calls
communicate with that peer only.
Sourcepub async fn ready(
&self,
interest: Interest,
) -> Result<AsyncFdReadyGuard<'_, Socket>>
pub async fn ready( &self, interest: Interest, ) -> Result<AsyncFdReadyGuard<'_, Socket>>
Wait for the socket to become ready for the given Interest.