This is a basic Simple Network Time Protocol (SNTP) client Class in B4J based on UDPSocket that can be used to retrieve the current time from NIST Internet Time Servers or local NTP servers on your LAN.
It includes a 4 second "delay" to prevent overuse (minimum of 4.1 seconds between Query method calls) with an Unblock event to signal when another request can be made. See the NIST page linked above.
The Response event returns the requested current date and time. Response also returns the Source of the time as reported by the time server (if any). Typical values are listed in RFC 5905 as:
These are not particularly useful in most programs though.
The attached demo shows use of the SNTPClient Class, which is included in the attached archive.
Reposted updated version 30-Dec-2013.
It includes a 4 second "delay" to prevent overuse (minimum of 4.1 seconds between Query method calls) with an Unblock event to signal when another request can be made. See the NIST page linked above.
The Response event returns the requested current date and time. Response also returns the Source of the time as reported by the time server (if any). Typical values are listed in RFC 5905 as:
B4X:
+------+----------------------------------------------------------+
| ID | Clock Source |
+------+----------------------------------------------------------+
| GOES | Geosynchronous Orbit Environment Satellite |
| GPS | Global Position System |
| GAL | Galileo Positioning System |
| PPS | Generic pulse-per-second |
| IRIG | Inter-Range Instrumentation Group |
| WWVB | LF Radio WWVB Ft. Collins, CO 60 kHz |
| DCF | LF Radio DCF77 Mainflingen, DE 77.5 kHz |
| HBG | LF Radio HBG Prangins, HB 75 kHz |
| MSF | LF Radio MSF Anthorn, UK 60 kHz |
| JJY | LF Radio JJY Fukushima, JP 40 kHz, Saga, JP 60 kHz |
| LORC | MF Radio LORAN C station, 100 kHz |
| TDF | MF Radio Allouis, FR 162 kHz |
| CHU | HF Radio CHU Ottawa, Ontario |
| WWV | HF Radio WWV Ft. Collins, CO |
| WWVH | HF Radio WWVH Kauai, HI |
| NIST | NIST telephone modem |
| ACTS | NIST telephone modem |
| USNO | USNO telephone modem |
| PTB | European telephone modem |
+------+----------------------------------------------------------+
These are not particularly useful in most programs though.
The attached demo shows use of the SNTPClient Class, which is included in the attached archive.
Reposted updated version 30-Dec-2013.
Attachments
Last edited: