Click here to Skip to main content
15,351,229 members
Articles / Programming Languages / C#
Posted 13 Mar 2001


96 bookmarked

SNTP Client in C#

Rate me:
Please Sign up or sign in to vote.
4.88/5 (39 votes)
27 Aug 2001CPOL
Implementation of the Simple Network Time Protocol (RFC 2030) in C#
  • Download source files - 12 Kb
  • Download demo project - 5 Kb

    Sample Image - ntpclient.jpg


    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. Maybe Michel reads this and will send me a note.

    There are several time severs on the Internet and the list below contains those operated by NIST. If you need more, use a search engine.

    NameIP AddressLocation
    time-a.nist.gov129.6.15.28NIST, Gaithersburg, Maryland
    time-b.nist.gov129.6.15.29NIST, Gaithersburg, Maryland
    time-a.timefreq.bldrdoc.gov132.163.4.101NIST, Boulder, Colorado
    time-b.timefreq.bldrdoc.gov132.163.4.102NIST, Boulder, Colorado
    time-c.timefreq.bldrdoc.gov132.163.4.103NIST, Boulder, Colorado
    utcnist.colorado.edu128.138.140.44University of Colorado, Boulder
    time.nist.gov192.43.244.18NCAR, Boulder, Colorado
    time-nw.nist.gov131.107.1.10Microsoft, Redmond, Washington
    nist1.datum.com209.0.72.7Datum, San Jose, California
    nist1.dc.certifiedtime.com216.200.93.8Abovnet, Virginia, New York City
    nist1.sjc.certifiedtime.com208.185.146.41Abovnet, San Jose, California

  • License

    This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


    About the Author

    Valer BOCAN
    Romania Romania
    I am a software engineer based in Timișoara, Romania and currently hold the position of software architect for one of the largest companies in the world.

    I invented a dialect of the Forth programming language and implemented the first Forth compiler for the .NET platform. I reverse-engineered the communication protocol of some GPS trackers and wrote from scratch a vehicle tracking system that is currently used to track my two cars. I hold a PhD in computer science and I am the author of several papers and a book chapter. In the 90s I wrote several computer viruses in assembly language for my own research and I was the first to devise a technique to deter heuristic virus scanners. In short, a humble man.

    Comments and Discussions

    QuestionInformatii militare Pin
    Member 155185695-Feb-22 23:32
    MemberMember 155185695-Feb-22 23:32 
    QuestionHow to Stop Code Pin
    Member 1041097226-Feb-19 6:46
    MemberMember 1041097226-Feb-19 6:46 
    QuestionMode name Pin
    Member 1412593422-Jan-19 1:24
    MemberMember 1412593422-Jan-19 1:24 
    Questionbugs with timeout implementation Pin
    Kirsan3116-Mar-16 8:03
    MemberKirsan3116-Mar-16 8:03 
    QuestionOnly one usage of each socket address runtime error Pin
    kerrywales217-Jun-15 22:53
    Memberkerrywales217-Jun-15 22:53 
    AnswerRe: Only one usage of each socket address runtime error Pin
    frinkfree11-Aug-15 11:13
    Memberfrinkfree11-Aug-15 11:13 
    GeneralRe: Only one usage of each socket address runtime error Pin
    Kirsan3116-Mar-16 6:44
    MemberKirsan3116-Mar-16 6:44 
    QuestionStill a great Project Pin
    Duane Penzien25-Apr-15 14:39
    MemberDuane Penzien25-Apr-15 14:39 
    GeneralThanks Pin
    Member 874252319-Nov-14 1:08
    MemberMember 874252319-Nov-14 1:08 
    QuestionLittle help Pin
    Member 1043345528-Nov-13 19:43
    MemberMember 1043345528-Nov-13 19:43 
    Questionntp Pin
    Marziyeh Eslampanah15-May-12 5:35
    MemberMarziyeh Eslampanah15-May-12 5:35 
    GeneralThanks for the code Pin
    M Daniel Engineering12-Apr-12 5:35
    MemberM Daniel Engineering12-Apr-12 5:35 
    GeneralTimeouts Pin
    malcomm11-Feb-11 22:55
    Membermalcomm11-Feb-11 22:55 
    GeneralRe: Timeouts Pin
    Romain TAILLANDIER8-Dec-11 23:42
    MemberRomain TAILLANDIER8-Dec-11 23:42 
    AnswerRe: Timeouts Pin
    Valer BOCAN8-Dec-11 23:56
    MemberValer BOCAN8-Dec-11 23:56 
    GeneralRe: Timeouts Pin
    Romain TAILLANDIER9-Dec-11 0:14
    MemberRomain TAILLANDIER9-Dec-11 0:14 
    NewsGreat little helper, has a leak Pin
    CodingBruce23-Feb-10 6:24
    MemberCodingBruce23-Feb-10 6:24 
    GeneralLicense Pin
    Captain Groovy4-Feb-10 14:00
    MemberCaptain Groovy4-Feb-10 14:00 
    GeneralRe: License Pin
    Valer BOCAN4-Feb-10 17:43
    MemberValer BOCAN4-Feb-10 17:43 
    Generalthanx Pin
    Murat DOGANCAY21-Feb-09 2:55
    MemberMurat DOGANCAY21-Feb-09 2:55 
    Generalhangs if no ip Pin
    wihe200818-Jul-08 19:27
    Memberwihe200818-Jul-08 19:27 
    GeneralRe: hangs if no ip Pin
    wihe200818-Jul-08 19:31
    Memberwihe200818-Jul-08 19:31 
    GeneralRe: hangs if no ip Pin
    wihe200818-Jul-08 20:55
    Memberwihe200818-Jul-08 20:55 
    Generalcommercial use Pin
    harmjonker14-Jul-08 6:19
    Memberharmjonker14-Jul-08 6:19 
    GeneralRe: commercial use Pin
    Valer BOCAN14-Jul-08 22:47
    MemberValer BOCAN14-Jul-08 22:47 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.