[ntp:questions] Any samples for NTP/SNTP client code?

Joseph Gwinn joegwinn at comcast.net
Sat Dec 1 20:07:16 UTC 2007


In article 
<90967f07-83ca-4d79-8acb-1c3056ce39a4 at l1g2000hsa.googlegroups.com>,
 guuwwe at hotmail.com wrote:

> Does anybody know of any *practical* samples on how to
> implement NTP/SNTP client?. The goal is to provide accurate
> time for a program/client running on Windows Vista.
> 
> Specifically, what values to include in the the request message,
> how to process the reply message, etc.
> 
> I am NOT asking how to send/receive UDP datagrams, or where
> to find comprehensive descriptions like RFC documents, or how
> to build or design user interfaces.
> 
> Only a narrow description focused on NTP/SNTP request/reply
> datagrams for a simple PC client, preferably in C/C++ source
> code.

I've done this in an embedded realtime system.  (No, the source code is 
not available.)  

In Appendix A of RFC-1305 you will find the format of the NTPv3 
request/response packet.  Send this packet to port 123 of the NTP 
server, and read the reply packet.  It's pretty easy.  

The NTPv3 packet format will work with all timeservers of NTPv3 and 
above.

Joe Gwinn




More information about the questions mailing list