[ntp:questions] Getting the version string programmatically ...

David J Taylor david-taylor at blueyonder.delete-this-bit.and-this-part.co.uk.invalid
Thu Dec 17 14:32:19 UTC 2009

"Martin Burnicki" <martin.burnicki at meinberg.de> wrote in message 
news:ttopv6-o6q.ln1 at gateway.py.meinberg.de...
> some time ago one of my colleagues has picked up the source code of ntpq 
> and
> applied some modifications and extensions so that he could build a DLL
> which provides the functionality of ntpq via some API calls exported by
> that DLL.
> Unfortunatly that colleague is currently out of the office (I think 
> he'll be
> back at latest next Monday), but AFAIR that DLL is shipped with the NTP
> Time Server Monitor for Windows:
> http://www.meinberg.de/english/sw/time-server-monitor.htm#download
> If I remember correctly you should have that program running on one or 
> more
> of your machines, so you may see if there's a ntpsvcio.dll on those
> machines.
> Also, if I remember correctly, you are programming in Delphi, so we need 
> to
> see if we can define function prototypes in Pascal which lets you Delphi
> applications call those DLL API functions. I'm not too familiar with 
> that
> DLL, so I'd like to wait until my colleague is back until we can make 
> some
> information available how to use that DLL.
> Unfortunately those DLL functions are currently not thread-safe, simply
> because the source code of ntpq uses some state information in global
> variables, which is absolutely OK for ntpq as a standalone application.
> Another colleague has recently started to upgrade the source code of the 
> to use the recent source code of ntpq. Once this has been done we are
> planning to see if can make the DLL threadsafe by collecting all those
> global variables in a structure, so one instance of that structure can 
> be
> used per thread to keep information of the state of a NTP connection.
> Martin

Martin, I do have that DLL, but it's from 08-Nov-2006, so perhaps from an 
earlier version of the monitor.  Yes, it has some useful looking 
functions, and it would be useful to see a Delphi header.  At the moment, 
I have two functions coded:

- ask the time - does a standard mode 3 client/server interaction and 
returns the full packet

- ask for version information - which I've coded to match an "ntp -c rv" 
exchange, with the idea of parsing the received packet, which I see 
contains a "version=...." string.  I'm writing that code right now.

So much simpler than what's in the DLL.


More information about the questions mailing list