Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/knsd/tokio-ping
Asynchronous ICMP pinging library
https://github.com/knsd/tokio-ping
Last synced: 2 days ago
JSON representation
Asynchronous ICMP pinging library
- Host: GitHub
- URL: https://github.com/knsd/tokio-ping
- Owner: knsd
- License: apache-2.0
- Created: 2017-12-04T05:29:53.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-02-24T09:54:30.000Z (11 months ago)
- Last Synced: 2024-12-26T10:08:27.399Z (10 days ago)
- Language: Rust
- Homepage: https://docs.rs/tokio-ping
- Size: 64.5 KB
- Stars: 39
- Watchers: 4
- Forks: 26
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# tokio-ping
[![Build Status](https://travis-ci.org/knsd/tokio-ping.svg?branch=master)](https://travis-ci.org/knsd/tokio-ping)
[![Latest Version](https://img.shields.io/crates/v/tokio-ping.svg)](https://crates.io/crates/tokio-ping/)
[![docs](https://docs.rs/tokio-ping/badge.svg)](https://docs.rs/tokio-ping)tokio-ping is an asynchronous ICMP pinging library.
# Usage example
Note, sending and receiving ICMP packets requires privileges.
```rust
extern crate futures;
extern crate tokio;extern crate tokio_ping;
use futures::{Future, Stream};
fn main() {
let addr = std::env::args().nth(1).unwrap().parse().unwrap();let pinger = tokio_ping::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
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or
http://opensource.org/licenses/MIT)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.