views:

116

answers:

2

I'm developing a client/server software, and I'm searching the best way to keep my client clocks in sync with the server clock.

Of course, I can't use NTP because I don't want to touch the system clock. I'm just trying to compute a timegap so that I can add it to every single datetime received from the server to convert it into a 'local time'

What I do for know is that :

  • I handle the TimeZone problems using GMT time

  • Server send its current time to Client upon connection, and Client subtract the server time from its time to compute the timegap.

This works great when network lag is constant (read "my LAN"...)

Unfortunately, I want my software to work on the Internet, and even on mobile clients, for which I've witnessed lag variations up to 1 minute.

For the software I'm working on, such a lag is not acceptable.

What would be a good strategy to compute the client/server timegap?


Last thing : I can send messages in both way (client to server AND server to client)

It's probably irrelevant, but the technology behind this is a .net WCF client using an httpbinding with some polling

A: 

You could ping the server on regular intervals to calculate the lag. I don't think you can get really close over the internet.

Ikke
+1  A: 

Why can't you use NTP? Of course the default thing for ntp is to set the system time, but that is not obligatory:

$ ntpdate -q ntp.ubuntu.com
server 91.189.94.4, stratum 2, offset -0.102597, delay 0.05426
 2 Mar 11:44:36 ntpdate[12239]: adjust time server 91.189.94.4 offset -0.102597 sec
innaM

related questions