sntpc 0.2.0

Library for making SNTP requests
Documentation

Build Status

Simple Rust NTP client

This crate provides a method for sending requests to NTP servers and process responses, extracting received timestamp

Documentation

https://docs.rs/sntpc

Installation

This crate works with Cargo and is on crates.io. Add it to your Cargo.toml like so:

[dependencies]
sntpc = "0.2"

By calling the request() method and providing a proper NTP pool or server you should get a valid synchronization timestamp:

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);
}

Lightweight system time synchronization

The sntpc crate contains the timesync application that may sync system time with the given NTP server

Command-line options

USAGE:
    timesync [OPTIONS]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -p, --port <port>        NTP server port [default: 123]
    -s, --server <server>    NTP server hostname [default: time.google.com]

This is the output of timesync -h.