Giter Club home page Giter Club logo

sntp-client's Introduction

A C# SNTP Client

This is the very C# SNTP client used by Microsoft in .NET Micro Framework.

SNTPClient is a C# class designed to connect to time servers on the Internet and fetch the current date and time using the Network Time Protocol (NTP). The implementation of the protocol is based on the RFC 2030.

Historically, this has been the very first piece of C# code I've written back in 2000, apart from the traditional "Hello, world!".

Usage:

try
{
	// Build the SNTP client
	var client = new SNTPClient();
	// Connect to server and specify a timeout
	client.Connect("0.pool.ntp.org", 5000);
	// See connection results
	Console.WriteLine(client.ToString());
}
catch (Exception ex)
{
	Console.WriteLine($"Error: {ex.Message}");
}

A typical response would be:

Connecting to 0.pool.ntp.org...
Leap indicator : No warning
Version number : 3
Mode : Server
Stratum : Secondary reference
Precision : 2.98023223876953E-08 s.
Poll interval : 1 s.
Reference ID : ftp.upcnet.ro (78.96.7.8)
Root delay : 31.0821533203125 ms.
Root dispersion : 18.6767578125 ms.
Round trip delay : 504.7738 ms.
Local clock offset : 2461.6131 ms.
Local time : 8/3/2019 11:23:18 AM

A list of NTP servers that you can connect to is maintained by the NTP pool project.

sntp-client's People

Contributors

vbocan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

tanchoi dawn-lc

sntp-client's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.