[I am having bit trouble with trusting my solution.. Need your help to make it reliable]
[I am not having much knowledge about low level details of Computer Systems, but i am good software developer ]
Server App talks with Multiple client Apps...And client apps can get disconnect (wireless network).. But they will keep working..
After say 5 hours, network is available.. now all client apps will commit data (commands - work done while disconnected) to the server and server will organize it based on time.
For this i have implemented SNTP as application component. (And i made sure server and client are not running time service)
And client will commit commands after setting timestamps relative to Server's (currently using System.currentTimeMillis() will go for System.nanoTime()).
Clients will get server time difference (SNTP Protocol) it at time of login (At the time of login, Client must be in network).
I want to know, that is it okay to rely on computer's internal clock???, [as client will not be able to sync for 5 hrs.]
[i don't want millisecond accuracy, Up to 1 second or 2 is okay.]
I think, it is generic issue....Is there any framework or project available which can help in this???]
Before software can be reusable, it first has to be usable. - Ralph Johnson
Hm... the worst-case-scenario would be that the user comes to the brilliant idea to adjust the time on his computer. So the answer to your question, if you can rely on the internal clock is: no! But to be honest I also don't have a bullet-proof solution. I would probably go with you solution and would add an extra thread, that would start counting the seconds as soon as the computer is offline and checks, as it becomes online again, if there are dramatic differences between the seconds counted in the thread and the time-difference between offline and reconnect from the internal clock. If there's a huge gap between those two values, you know you can't trust the timestamps.
But I don't know if this method I accurate enough, especially if the cpu has a high load during the offline-period and the thread is not able to count *exactly* one second. If this would give you trouble Suns Java Real-Time System might be solution (http://java.sun.com/javase/technologies/realtime/index.jsp).
Due to the fact you haven't mentioned what kind of data you are proceeding a few questions: What happens if the data of one client is lost? What happens if the order is not correct? And is there a chance to increase the intervall to, let's say, 10 seconds?
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: About Syncronizing time between clients and a server.