客户端/服务器如何同步客户端上的方法执行 [英] Client/Server how to synchronize methods execution on clients

查看:85
本文介绍了客户端/服务器如何同步客户端上的方法执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个简单的客户端服务器应用程序,该应用程序允许服务器向将同时运行方法的所有客户端发送命令.
如何确保客户端将同时执行该方法?(延迟时间为毫秒)
我以为可以使用SNTP,但是我不知道如何集成它.
有什么建议吗?


我需要在LAN环境中完全同时开始播放视频.
该视频在客户端计算机上(不广播).
客户端计算机之间的播放必须同步
最多应支持50个客户.
服务器机器将在(50米)附近
[/编辑]

对不起,英语不好

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?


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

推荐答案

使用Windows时间服务 [ ^ ].服务器可以在所有客户端上添加计划的作业,以在指定的时间启动并运行一次,因为它们将在适当的时候由服务器重新计划.


请注意:但是,Windows时间服务无法比1-2秒范围更准确地维护系统时间" (Wiki参考 [ ^ ]).

因此,如果同时" 表示您的要求可以相差1-2秒,那么这可能是一个可行的解决方案.对于设置,运行,删除远程计算机上的任务的出色工具,请使用CodeProjects自己的 TaskScheduler库 [ ^ ] www.codeproject.com/script/Membership/View.aspx?mid=39096">Dennis Austin [ David Hall ''s [ CodePlex上的TaskScheduler库 [ ^ ]也值得一看. br/>
我希望这能帮到您.只要Windows Time Service同步的准确性足以满足您的应用程序,就应该没问题.

最好的问候和快乐的编码,

-MRB
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


我将其添加为单独的解决方案,因为从一开始就不知道这些要求.

I''ve added this as a separate solution since the requirements where not known from the start.


  1. 我想这些机器仅专用于此任务,除了播放在多个屏幕上播放的一个视频外,没有其他目的
  2. 在机器启动时让应用程序运行.
  3. li>
  4. 当应用程序启动并配置为运行视频(LAN)时,机器会向服务器发送某种就绪信号.
  5. 每个客户端都有一个小的硬件模块,可用于输入一个说12V的信号.当服务器通过LAN发出即将开始播放的信号时,将不断轮询输入.这是繁忙的等待过程,因此应该只在很小的时间间隔内发生.客户端需要确认他们现在处于轮询模式(也通过LAN)
  6. 将客户端置于轮询模式(包括等待所有客户端确认已这样做)之后,服务器将发送通过一些专用的HW(输出12V信号)通过屏蔽电缆向所有客户端发出信号,这些电缆的长度应相同.
  7. 在轮询指示后,客户端便开始播放视频并确认通过LAN发送到服务器
  8. 也可以通过LAN发送停止信号,因为它并不那么重要.
  9. 在您的情况下,您还可以让服务器在上面广播时间戳由于所有机器都靠近局域网,因此延迟的差异可以忽略不计.对于各种各样的事情来说,这是很不错的,其中的一种事情是能够确定客户端是否及时响应服务器的服务请求.

  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!


这篇关于客户端/服务器如何同步客户端上的方法执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆