Struct oping::Ping
[−]
[src]
pub struct Ping { // some fields omitted }
A Ping
struct represents the state of one particular ping instance:
several instance-wide options (timeout, TTL, QoS setting, etc.), and
a list of hostnames/addresses to ping. It is consumed when a single set
of ping packets are sent to the listed destinations, resulting in an
iterator over the responses returned.
Methods
impl Ping
fn new() -> Ping
Create a new Ping
context.
fn set_timeout(&mut self, timeout: f64) -> PingResult<()>
Set the timeout, in seconds, for which we will wait for replies from all listed destinations.
fn set_ttl(&mut self, ttl: i32) -> PingResult<()>
Set the TTL to set on the ping packets we send. Note that if a packet is sent with a TTL that is too low for the route, it may be dropped.
fn set_addr_family(&mut self, af: AddrFamily) -> PingResult<()>
Set the preferred address family to use: IPv4 or IPv6.
fn set_qos(&mut self, qos: u8) -> PingResult<()>
Set the value of the "quality of service" field to use on outgoing ping packets.
fn add_host(&mut self, hostname: &str) -> PingResult<()>
Add a ping destination. hostname
may be a hostname to look up via
the system's name resolution (DNS, etc), or a numeric IPv4 or IPv6
address.
Note that this method is the point at which a ping socket is actually created. Hence, if the program does not have the appropriate permission to send ping packets, this is usually where the error will occur.
fn remove_host(&mut self, hostname: &str) -> PingResult<()>
Remove a destination that was previously added. If the hostname does not match one that was added previously, an error will be returned.
fn send(self) -> PingResult<PingIter>
Sends a single ping to all listed destinations, waiting until either replies are received from all destinations or the timeout is reached. Returns an iterator over all replies.
A Ping
context may only be used once; hence, this method consumes
the context.