2 releases

0.4.1 Mar 17, 2022
0.4.0 Apr 27, 2021

#14 in #icmp

Download history 142/week @ 2024-04-18 172/week @ 2024-04-25 114/week @ 2024-05-02 76/week @ 2024-05-09 79/week @ 2024-05-16 101/week @ 2024-05-23 124/week @ 2024-05-30 118/week @ 2024-06-06 136/week @ 2024-06-13 118/week @ 2024-06-20 61/week @ 2024-06-27 30/week @ 2024-07-04 49/week @ 2024-07-11 206/week @ 2024-07-18 63/week @ 2024-07-25 90/week @ 2024-08-01

415 downloads per month
Used in peshming

MIT/Apache

28KB
692 lines

tokio-icmp-echo

Latest Version docs

tokio-icmp-echo is an asynchronous ICMP pinging library. It was originally written by Fedor Gogolev, a.k.a. knsd, and distributed under the name tokio-ping. This here is a fork that includes mostly maintenance work, to make sure it works in the current state of the async rust ecosystem.

Usage example

Note, sending and receiving ICMP packets requires privileges.

extern crate futures;
extern crate tokio;

extern crate tokio_icmp_echo;

use futures::{Future, Stream};

fn main() {
    let addr = std::env::args().nth(1).unwrap().parse().unwrap();

    let pinger = tokio_icmp_echo::Pinger::new();
    let stream = pinger.and_then(move |pinger| Ok(pinger.chain(addr).stream()));
    let future = stream.and_then(|stream| {
        stream.take(3).for_each(|mb_time| {
            match mb_time {
                Some(time) => println!("time={}", time),
                None => println!("timeout"),
            }
            Ok(())
        })
    });

    tokio::run(future.map_err(|err| {
        eprintln!("Error: {}", err)
    }))
}

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~4–14MB
~151K SLoC