Click here to Skip to main content
15,353,748 members
Articles / Programming Languages / C#
Article
Posted 13 Mar 2001

Stats

362.2K views
14.4K downloads
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

    Introduction

    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
    nist1.nyc.certifiedtime.com208.184.49.9Abovnet, 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)

    Share

    About the Author

    Valer BOCAN
    Architect
    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

     
    GeneralUsing IP addresses rather than hostnames Pin
    MrEyes27-May-05 5:46
    MemberMrEyes27-May-05 5:46 
    GeneralNeed urgent Help Pin
    PShweta6-Oct-04 23:59
    MemberPShweta6-Oct-04 23:59 
    GeneralRe: Need urgent Help Pin
    Valer BOCAN7-Oct-04 0:53
    MemberValer BOCAN7-Oct-04 0:53 
    Generalminor bug : Peer clock precision calculation Pin
    EzekielDA10-Jun-04 11:40
    MemberEzekielDA10-Jun-04 11:40 
    GeneralRe: minor bug : Peer clock precision calculation Pin
    Valer BOCAN14-Jun-04 6:02
    MemberValer BOCAN14-Jun-04 6:02 
    GeneralDoesn't Run on WinXP Pro Pin
    sandman_max4-May-04 2:36
    Membersandman_max4-May-04 2:36 
    GeneralRe: Doesn't Run on WinXP Pro Pin
    Valer BOCAN14-Jun-04 6:04
    MemberValer BOCAN14-Jun-04 6:04 
    GeneralDoesn't work with W2K server Pin
    rahulN19-Jan-04 22:29
    MemberrahulN19-Jan-04 22:29 
    This sample doesn't work when we retrieve the time from a W2K machine. If instead of the specified servers, any W2K machne is specified as the server, the application throws an exception "An existing connection was forcibly closed by the remote host". Is there any solution to this?
    GeneralRe: Doesn't work with W2K server Pin
    Valer BOCAN3-Feb-04 0:20
    MemberValer BOCAN3-Feb-04 0:20 
    GeneralWindows CE Compatibility Pin
    RFID Chris4-Dec-03 5:59
    MemberRFID Chris4-Dec-03 5:59 
    GeneralJava implementation of a NTP client by Michel Van den Bergh, Pin
    Kavitha Gopal21-Oct-03 21:45
    sussKavitha Gopal21-Oct-03 21:45 
    GeneralRe: Java implementation of a NTP client by Michel Van den Bergh, Pin
    Anonymous29-Sep-05 6:25
    MemberAnonymous29-Sep-05 6:25 
    GeneralServer Timeout Pin
    Wayland Young8-Jul-03 5:42
    professionalWayland Young8-Jul-03 5:42 
    GeneralRe: Server Timeout Pin
    Norberto Olazabal11-Nov-04 12:08
    MemberNorberto Olazabal11-Nov-04 12:08 
    AnswerRe: Server Timeout Pin
    jdn492927-Apr-06 10:31
    Memberjdn492927-Apr-06 10:31 
    GeneralRe: Server Timeout Pin
    segato20-Jun-06 2:18
    Membersegato20-Jun-06 2:18 
    GeneralRe: Server Timeout Pin
    djlove24-Feb-09 22:52
    Memberdjlove24-Feb-09 22:52 
    AnswerRe: Server Timeout Pin
    dazza19763-Mar-08 20:26
    Memberdazza19763-Mar-08 20:26 
    GeneralSuggestion Pin
    Jeffrey Sax21-May-03 15:01
    MemberJeffrey Sax21-May-03 15:01 
    GeneralRe: Suggestion Pin
    djlove24-Feb-09 22:48
    Memberdjlove24-Feb-09 22:48 
    GeneralChanged the client code Pin
    Ramon Smits10-Apr-03 7:12
    MemberRamon Smits10-Apr-03 7:12 

    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.