RE: [GD-Windows] More timer fun!
Brought to you by:
vexxed72
From: Jon W. <hp...@mi...> - 2002-09-03 17:05:03
|
> Could you share some insight as to doing this with some > reliability? In most Well, the source code for NTP is rather more authoritative than I could ever be :-) However, a quick-and-dirty way (which I've used privately in the past) might include setting up your packets such that, from the clients point of view: - tack on current time when sending - server returns your-send-time + server-reply-time on the reply - you receive a packet containing your-send-time, and at this point compare server-reply-time to your-receive-time, your-send-time Note that the round-trip time is now known. The server's time must be in the range of your-send-time through your-receive-time, with a tendency towards the center of that range (assuming symmetric round trips). You can know to immediately adjust your clock if the server's own notion of time is outside this range; a good place to adjust to is such that the center of your window lines up with the server-reply- time. But, as I said, for a less quick-and-dirty way to do it, you should go to some authoritative source. (Maybe a pun was intended there :-) Cheers, / h+ |