Step 5: Write Code to Synchronise Time

Step 6: Finish Up

At this point I had a working 1950's Clock which would sync to an extremely accurate network time server every hour. It looks great and is a great ble...

Step 5: Write Code to Synchronise Time

The time synchronisation code ended up proving the most difficult. I had originally intended to use NTP (Network Time Protocol) to get the time, however I was unable to get this to work with the web server. Instead I ended up implementing the simpler DAYTIME protocol. This involves connecting to port 13 on a given sever, which then automatically responds with the time in a known format. The code parses this and updates its internal time accordingly.

Two possible server addresses are used. If one fails then the other is tried. These are queried on startup, and every hour afterwards. The DAYTIME server sites recommend you limit how often you query them, and may block your address if abused.