pub struct Pinger { /* private fields */ }Expand description
A pinger that blocks when sending.
This is cheap to clone - clones share the underlying ICMP handles - and is
Send + Sync, so a single Pinger can be shared across threads. Note that
each send needs its own Buffer, as send takes it by &mut.
Implementations§
Source§impl Pinger
impl Pinger
Sourcepub fn new() -> Result<Self, CreateError>
pub fn new() -> Result<Self, CreateError>
Creates a new Pinger. If one ICMP handle (v4 or v6) fails to initialize, this will return the Pinger embedded in an error. The Pinger is still usable in this state, but sending on the failed version will return an Error. If both v4 and v6 fail, the pinger is not embedded in the error.
Sourcepub fn new_v4() -> Option<Self>
pub fn new_v4() -> Option<Self>
Creates a new Pinger, ignoring v6 failures. If you want to use both v4 and v6, use new() instead.
Sourcepub fn new_v6() -> Option<Self>
pub fn new_v6() -> Option<Self>
Creates a new Pinger, ignoring v4 failures. If you want to use both v4 and v6, use new() instead.
Sourcepub fn set_timeout(&mut self, timeout: u32)
pub fn set_timeout(&mut self, timeout: u32)
Sets the timeout, in milliseconds, for future requests.
Sourcepub fn send4(&self, dst: Ipv4Addr, buf: &mut Buffer) -> Result<u32, Error>
pub fn send4(&self, dst: Ipv4Addr, buf: &mut Buffer) -> Result<u32, Error>
Send an ICMPv4 request to the destination address. On success, returns the round trip time in milliseconds.
Sourcepub fn send4_from(
&self,
src: Ipv4Addr,
dst: Ipv4Addr,
buf: &mut Buffer,
) -> Result<u32, Error>
pub fn send4_from( &self, src: Ipv4Addr, dst: Ipv4Addr, buf: &mut Buffer, ) -> Result<u32, Error>
Sends an ICMPv4 request from the source address to the destination address. On success, returns the round trip time in milliseconds.
Sourcepub fn send6(&self, dst: Ipv6Addr, buf: &mut Buffer) -> Result<u32, Error>
pub fn send6(&self, dst: Ipv6Addr, buf: &mut Buffer) -> Result<u32, Error>
Sends an ICMPv6 request to the destination address. On success, returns the round trip time in milliseconds.
Sourcepub fn send6_from(
&self,
src: Ipv6Addr,
dst: Ipv6Addr,
buf: &mut Buffer,
) -> Result<u32, Error>
pub fn send6_from( &self, src: Ipv6Addr, dst: Ipv6Addr, buf: &mut Buffer, ) -> Result<u32, Error>
Sends an ICMPv6 request from the source address to the destination address. On success, returns the round trip time in milliseconds.