[ntp:questions] Getting the time from NTP

Danny Mayer mayer at ntp.org
Tue Dec 8 03:18:43 UTC 2009

Dave Hart wrote:
> On Dec 6, 6:50 UTC, "David J Taylor" wrote:
>> "Dave Hart" <daveh... at gmail.com> wrote
>>> I am guessing you're actually in a better position than me to provide
>>> a DLL exposing a function to get the time from ntpd.  There is no way
>>> other than a NTP packet to request a timestamp from ntpd.
>> Dave, thanks for that.  I must be missing something here, although I
>> haven't been able to check the source code.  Is there not a routine
>> somewhere inside ntpd.exe which timestamps the packets in response to a
>> request over the network?  How else are the packets timestamped?  Could
>> not that routine be exposed, or the variables it uses?  
> If we wanted to define a new Windows-only service provided by ntpd,
> sure, there could be some combination of shared memory and IPC objects
> like named events used to expose a way for another program to ask ntpd
> to go down its timestamping path and provide the result.  There's no
> need on non-Windows systems where the system clock is high precision
> and typically interpolated.  Such a mechanism would be a potential
> local DoS avenue again unique to Windows, which while popular in
> general, isn't the center of the NTP universe.
> The reason I suggested you are in a better position than me to provide
> that capability is you've already written code that runs on Windows
> and retrives the time via a NTP request/reply pair of packets.  Wire
> it to [::1]:123 and/or and there's your ntpGetTime().

Why on earth would you do this? Just copy the get_systime() function and
be done:


It's in systime.c.


P.S. [::1]:123 is not a valid IPv6 address. The IPv6 address is ::1. The
normal way to write the above is ::1#123.


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

More information about the questions mailing list