An interesting piece of code this, all the more so since it is this guy’s first go with c#. I use it to synch my laptop with time.windows.com – yes, I know XP has the same built in, but it only synchronises once per week, and I prefer to schedule a synch on startup. The Code Project has an out-of-date version of this, but Valer Bocan’s site maintains the latest, a discussion board for it and a VB port of the class. However, you just need the class, adjusting the namespace to suit, and adding a reference to mscorlib in your project. Using it is simple:
string TimeServer = "time.windows.com";
client = new NTPClient(TimeServer);
client.Connect(false);
to synchronise the local machine with the time server just use:
client.Connect(true);
that’s it.
