Click here to Skip to main content
12,547,231 members (64,168 online)
Click here to Skip to main content
Add your own
alternative version


96 bookmarked

SNTP Client in C#

, 27 Aug 2001 CPOL
Rate this:
Please Sign up or sign in to vote.
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.

    Name IP Address Location NIST, Gaithersburg, Maryland NIST, Gaithersburg, Maryland NIST, Boulder, Colorado NIST, Boulder, Colorado NIST, Boulder, Colorado University of Colorado, Boulder NCAR, Boulder, Colorado Microsoft, Redmond, Washington Datum, San Jose, California Abovnet, Virginia Abovnet, New York City Abovnet, 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.

    You may also be interested in...


    Comments and Discussions

    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
    bruceme10123-Feb-10 6:24
    memberbruceme10123-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 
    QuestionDaylight Time saving Pin
    XadhoomGrglblstr6-Apr-08 22:47
    memberXadhoomGrglblstr6-Apr-08 22:47 
    AnswerRe: Daylight Time saving [modified] Pin
    Geoff Low (NZ)5-Jun-08 15:56
    memberGeoff Low (NZ)5-Jun-08 15:56 
    GeneralThe program block Pin
    NanakiFire2-Apr-08 3:34
    memberNanakiFire2-Apr-08 3:34 
    GeneralNTP in Compact Framework Pin
    IowaEric8-Jun-07 5:56
    memberIowaEric8-Jun-07 5:56 
    GeneralRe: NTP in Compact Framework Pin
    IowaEric24-Oct-07 15:51
    memberIowaEric24-Oct-07 15:51 
    GeneralRe: NTP in Compact Framework Pin
    beimklabautermann3-Jun-10 5:38
    memberbeimklabautermann3-Jun-10 5:38 
    GeneralNIce article Pin
    Vikas Salvi3-Mar-07 2:21
    memberVikas Salvi3-Mar-07 2:21 
    AnswerRe: NIce article Pin
    NetDave25-Apr-07 6:48
    memberNetDave25-Apr-07 6:48 
    GeneralExecution on Pocket PC Emulator Pin
    Rashmi C13-Dec-06 1:16
    memberRashmi C13-Dec-06 1:16 
    GeneralGet Server time Pin
    try.kret8-Oct-06 17:14
    membertry.kret8-Oct-06 17:14 
    AnswerRe: Get Server time Pin
    Valer BOCAN8-Oct-06 17:23
    memberValer BOCAN8-Oct-06 17:23 
    GeneralRe: Get Server time Pin
    try.kret8-Oct-06 17:49
    membertry.kret8-Oct-06 17:49 
    GeneralRe: Get Server time Pin
    try.kret9-Oct-06 15:32
    membertry.kret9-Oct-06 15:32 
    QuestionUrgent:- Implementation of the Network Time protocol (RFC 13905) in C++ Pin
    Kulkarni Abhijit27-Jul-06 0:49
    memberKulkarni Abhijit27-Jul-06 0:49 
    GeneralThanks!! Pin
    Micah Wedemeyer23-Dec-05 4:24
    memberMicah Wedemeyer23-Dec-05 4:24 
    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 
    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
    sussAnonymous29-Sep-05 6:25 
    GeneralServer Timeout Pin
    wey978-Jul-03 5:42
    memberwey978-Jul-03 5:42 

    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.

    | Advertise | Privacy | Terms of Use | Mobile
    Web02 | 2.8.161018.1 | Last Updated 28 Aug 2001
    Article Copyright 2001 by Valer BOCAN
    Everything else Copyright © CodeProject, 1999-2016
    Layout: fixed | fluid