C# SNTP Client

Environment: Visual Studio.NET Beta 1

Though not obvious, time synchronization is sometimes important. The best example is the Kerberos authentication protocol, which requires the resources to be synchronized within minutes or even seconds, but there are other situations as well. The Network Time Protocol (NTP) and its simplified form (SNTP) are widely used to synchronize network resources, due to their simplicity and effectiveness. There are many programs available that synchronize your PC's clock with that of a time server. Dimension 4 is my favorite.

In case you need time synchronization embedded into your software, here is the C# alternative. It's simple, fast and integrates seamlessly with the .NET platform. There is a Java implementation of a NTP client by Michel Van den Bergh, but I don't have the URL anymore. If Michel (or anyone else that knows it) reads this and emails me, then I'll update the article.

There are several time severs on the Internet and the list below contains those operated by NIST. If you need more, you can probably find a few more using any standard Internet search engine.

Name IP Address Location
time-a.nist.gov NIST, Gaithersburg, Maryland
time-b.nist.gov NIST, Gaithersburg, Maryland
time-a.timefreq.bldrdoc.gov NIST, Boulder, Colorado
time-b.timefreq.bldrdoc.gov NIST, Boulder, Colorado
time-c.timefreq.bldrdoc.gov NIST, Boulder, Colorado
utcnist.colorado.edu University of Colorado, Boulder
time.nist.gov NCAR, Boulder, Colorado
time-nw.nist.gov Microsoft, Redmond, Washington
nist1.datum.com Datum, San Jose, California
nist1.dc.certifiedtime.com Abovnet, Virginia
nist1.nyc.certifiedtime.com Abovnet, New York City
nist1.sjc.certifiedtime.com Abovnet, San Jose, California

The server time.nist.gov yields the following results:

The NTPClient class is simply to use. Follow the example below:

NTPClient client;
 client = new NTPClient("time.nist.gov");
catch(Exception e)
 Console.WriteLine("ERROR: {0}", e.Message);


Download source - 4 Kb
Download demo project - 7 Kb


  • utc time

    Posted by arvind on 03/15/2013 08:26am

    hello, thanks for the effort. is there a method for GMT time.

  • Latest version...

    Posted by scamurra on 09/22/2010 04:35pm

    Hello, How can I get a version that will compile in .NET 2 or 3.5? Thanks

  • Timing Accuracy Issue

    Posted by ppledge on 03/25/2008 09:15am

    Nice Article, excellent class. I am concerned however that you use the DateTime for time stamping incoming messages. Although the DateTime class has room and drags digits out to the nanosecond range, it is only updated by windows every 10-15 milliseconds or so (easy to check out, get the time in a for loop and output it to a file or display, you will see that it doesn't change). In order to get real millisecond accuracy, you need someting like a performance timer synchronized to the windows clock. Other then that, it is excellent. p

  • Can't compile demo project...

    Posted by Legacy on 06/11/2003 12:00am

    Originally posted by: xaero

    I Can't compile your demo project.

  • Java Version

    Posted by Legacy on 03/09/2003 12:00am

    Originally posted by: Damian Penney

    Found the Van Den Bergh Java implementation at http://alpha.luc.ac.be/cgi-bin/Research/Algebra/java.cgi

  • Please add project in VS6.0, too

    Posted by Legacy on 11/02/2001 12:00am

    Originally posted by: MartinBi

    I would like to use you class in Visual Studio 6.0,
    but you add only VS7.0 projects.
    Please correct this problem.

    Thank you
    Martin, Poland

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Lenovo recommends Windows 8 Pro. "I dropped my laptop getting out of the taxi." This probably sounds familiar to most IT professionals. If your employees are traveling, you know their devices are in for a rough go. Whether it's a trip to the conference room or a convention out of town, any time equipment leaves a user's desk it is at risk of being put into harm's way. Stay connected at all times, whether at the office or on the go, with agile, durable, and flexible devices like the Lenovo® …

  • Moving from an on-premises environment to Office 365 does not remove the need to plan for disruptions or reduce the business risk requirements for protecting email services. If anything, some risks increase with a move to the cloud. Read how to ease the transition every business faces if considering or already migrating to cloud email. This white paper discusses: Setting expectations when migrating to Office 365 Understanding the implications of relying solely on Exchange Online security Necessary archiving …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date