com.mindprod.setclock
Class MiniSNTP

java.lang.Object
  extended by com.mindprod.setclock.MiniSNTP

public final class MiniSNTP
extends java.lang.Object

handles SNTP Simple Network Time Protocol to ask the time of an atomic clock.

see RFC 1769 for a full description of the datagram. The packet is written in big-endian binary format. Timestamps in the packets are in scaled unsigned seconds since Jan 1, 1900 0:00, with 32 bits of integer and 32 bit of binary fracion.

set PC Clock from an atomic clock.

Since:
1999
Version:
8.3 2008-09-23 - fix problem with Microsoft C++ runtime library.
Author:
Roedy Green, Canadian Mind Products

Method Summary
static long correction(java.lang.String ntpServer)
          Calculate how far out local time is from what server says: Positive result means local clock is running, slow, it requires a number added to it to give the correct time.
protected  void dump()
          debugging dump of state variables
static void main(java.lang.String[] args)
          test harness
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

correction

public static long correction(java.lang.String ntpServer)
Calculate how far out local time is from what server says: Positive result means local clock is running, slow, it requires a number added to it to give the correct time. A negative result means local clock is running fast.

Parameters:
ntpServer - domain or IP of ntp server no http:// on ntp:// on front.
Returns:
how many milliseconds fast the local PC clock is running. returns Long.MAX_VALUE if it cannot provide an accurate correction.

dump

protected void dump()
debugging dump of state variables


main

public static void main(java.lang.String[] args)
test harness

Parameters:
args - not used