pub struct IcmpSocket { /* private fields */ }Expand description
ICMP socket wrapper that handles both raw and DGRAM sockets
Implementations§
Source§impl IcmpSocket
impl IcmpSocket
Sourcepub fn new() -> PingResult<Self>
pub fn new() -> PingResult<Self>
Create a new ICMP socket
This attempts to create a DGRAM socket first (non-root), then falls back to a raw socket (requires root privileges) if needed.
Sourcepub fn connect(&self, target: Ipv4Addr) -> PingResult<()>
pub fn connect(&self, target: Ipv4Addr) -> PingResult<()>
Connect the socket to a target address (only for raw sockets)
Sourcepub fn send(
&self,
packet: &IcmpPacket,
target: Option<Ipv4Addr>,
) -> PingResult<usize>
pub fn send( &self, packet: &IcmpPacket, target: Option<Ipv4Addr>, ) -> PingResult<usize>
Send an ICMP packet
Sourcepub fn recv(
&self,
timeout: Duration,
) -> PingResult<(IcmpPacket, Ipv4Addr, Option<u8>)>
pub fn recv( &self, timeout: Duration, ) -> PingResult<(IcmpPacket, Ipv4Addr, Option<u8>)>
Receive an ICMP packet
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IcmpSocket
impl RefUnwindSafe for IcmpSocket
impl Send for IcmpSocket
impl Sync for IcmpSocket
impl Unpin for IcmpSocket
impl UnwindSafe for IcmpSocket
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