How to Use an Internet Time Server to Get the Time

Getting time from public time server using TimeTCPClient

NTP is a different protocol than the time protocol. NTP servers only talk over port UDP/123. Time servers use TCP/37 (which TimeTCPClient appears to implement correctly).

If you want to get a remote time, use an appropriate server (ntp.xs4all.nl appears to be listening on the time port).

.Net API to get exact time for Internet Time Server

There's a third party library that should bail you out. See the NtpClient class

For other alternatives, see the similar thread here

Java: Get current Date and Time from Server not System clock

You could have a look at the Java NTP Client demo available at

http://www.docjar.com/html/api/examples/ntp/NTPClient.java.html

and some example code that utilizes this client

http://www.docjar.com/html/api/examples/ntp/TimeClient.java.html

It's about 170 lines of well documented java code.

How can I query online time servers to get the accurate time

You should not do this from your application code. As you are pointing out there are "some time servers that are used by Windows to auto-update time over internet." So, use an appropriate client program/service to set your server's time on a regular bases. This way your server's clock will always be accurate to the microsecond level. Attempting to query a time-server on a per request bases (as your description suggests) is foolish and causes a great deal of unnecessary overhead.



Related Topics



Leave a reply



Submit