This crate provides a method for sending requests to NTP servers and process responses, extracting received timestamp
https://docs.rs/sntpc
This crate works with Cargo and is on
crates.io. Add it to your Cargo.toml
like so:
toml
[dependencies]
sntpc = "0.2"
By calling the request()
method and providing a proper NTP pool or server you
should get a valid synchronization timestamp:
```rust use sntpc;
let result = sntpc::request("pool.ntp.org", 123); if let Ok(sntpc::NtpResult { sec, nsec, roundtrip, offset }) = result { println!("NTP server time: {}.{}", sec, nsec); println!("Roundtrip time: {}, offset: {}", roundtrip, offset); } ```
The sntpc
crate contains the timesync
application that may sync system
time with the given NTP server
``` USAGE: timesync [OPTIONS]
FLAGS: -h, --help Prints help information -V, --version Prints version information
OPTIONS:
-p, --port
This is the output of timesync -h
.