Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I need a simple client server application that allows the server to send a command to all clients that will run a method at the same time.
How can I make sure that the clients will perform the method at the same time?(milliseconds of delay)
I thought the use of SNTP but I do not know how to integrate it.
Any suggestions?

[Edit]
I need to start a video at exactly the same time on a LAN enviroment.
The video is on client machines (No broadcast).
The playback between client machines must be synchronized
Should support up to 50 clients.
The server machine will be near (50 meters)
[/Edit]

Sorry for bad english
Posted
Updated 4-Jun-11 7:26am
v7

Synchronize your computers via NTP (> Windows 2000) or SNTP (<= Windows 2000) using the Windows Time Service[^]. The server could add scheduled jobs on all clients to start at a specified time and run once as they'll be rescheduled by the server when appropriate.


Beware though: "However, the Windows Time Service cannot maintain the system time more accurately than about a 1-2 second range" (Wiki Reference[^]).

So if "at the same time" means that a difference of 1-2 seconds is OK by your requirements, this might be a viable solution. For a great tool to setup, run, delete tasks on remote machines use CodeProjects own TaskScheduler Library[^] written by Dennis Austin[^]. David Hall's[^] TaskScheduler Library on CodePlex[^] is also worth a look.

I hope this will help you. It should be no problem as long as the accuracy of Windows Time Service synchroization is good enough for your application.

Best Regards and happy coding,

-MRB
 
Share this answer
 
v4
Comments
Morph King 4-Jun-11 12:52pm    
I need to start a video at exactly the same time, we are talking about milliseconds of delay
Manfred Rudolf Bihy 4-Jun-11 12:56pm    
What kind application is that? A video should be broadcast by a streaming server and the clients would receive it if the proper application was previously started before the broadcast.
You will have to lay out your exact requirements to get real good help.
Manfred Rudolf Bihy 4-Jun-11 13:01pm    
Milliseconds are not realistic in a network environment. Especially when in a WAN environment you'd have to cope with latencies too.
Morph King 4-Jun-11 13:01pm    
The video is already on the client machines, when the server sends the command the clients must start the playback at exactly the same time.
it's a LAN Network.
Manfred Rudolf Bihy 4-Jun-11 13:03pm    
You still have not come up with a plausible reason for why this would have to be at the exact same time. Please explain.
I've added this as a separate solution since the requirements where not known from the start.


  1. I presume the machines are dedicated to this task only and don't have any other purpose than to play one video spread over several screens
  2. Have the application run when the machines are started.
  3. The machines send some sort of ready signal to the server when the application is started and configured to run the video (LAN).
  4. Each client has a small HW module that allows for input of a say 12V signal. The input is polled constantly when the server has signaled via LAN that playing is about to start. This is busy waiting and should thus only take place for a small time interval. The clients need to acknowledge that they are now in polling mode (also over LAN)
  5. After putting the clients into polling mode (including having waited for all of them to acknowledge having done so) the server will send a signal to all clients via some dedicated HW (output 12V signal) over shielded cables which should be all of the same length.
  6. As soon as the polling indicates it, the clients start to play the video and acknowledge that over LAN to the server
  7. Sending a stop signal could also be done via LAN as it is not that critical.
  8. In your scenario you could also have the server broadcast a time stamp over the LAN as all machines are close together differences in latency will be negligible. This would be nifty for all sorts of things one of which being able to decide if a client responded in a timely fashion to a service request by the server.


How about that scenario?

Cheers!
 
Share this answer
 
Comments
Morph King 4-Jun-11 14:29pm    
I need to use only standard HW and ethernet connections.
There is no some time sync method to achieve it?
Espen Harlinn 5-Jun-11 6:24am    
Good effort - my 5+5 (for the other reply)
Manfred Rudolf Bihy 5-Jun-11 7:53am    
Thanks and thanks, Espen. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900