使用循环屏障实现服务器与客户端之间的持续通信。

huangapple 未分类评论45阅读模式
英文:

Use of CyclicBarriers for ongoing communication between server and client(s)

问题

我已经为服务器和客户端之间的通信设置了套接字,并在服务器上运行线程以处理多个客户端连接。此外,我现在正在服务器和客户端之间发送字节数组以进行数据传输,然而我在考虑实现循环屏障以使服务器在特定数量的客户端连接之前等待,然后再向每个客户端发送不同的消息。

这种通信和等待需要持续进行,例如,一旦达到客户端连接的阈值并发送出消息,服务器现在应再次等待来自每个客户端的消息,可能是不同的消息。这应该至少持续几次迭代,我想知道我是否可以通过为这个过程实现循环屏障来找到最佳解决方案?

这是循环屏障的预期用途吗?还是我这个想法有更好的替代方案?

为了简单起见,我打算等待连接的客户端数量为2个。还将强制执行超时条件以处理可能的故障。

英文:

I've set up sockets for communication between a server and client and have threads running on the server for multiple client connections. Furthermore I'm now sending byte arrays between server and client for data however I'm thinking of implementing cyclic barriers to make the server wait for a specific number of clients to connect before a different message is sent to each client.

This communication and waiting will need to be ongoing for example once this threshold of client connections is made and the message sent out, the server should now wait again for a message to come back from each client, probably a different message. This should continue for a few iterations at least, I'm wondering if I implement cyclic barriers for this process would i go be finding the best solution to this process?

Is this the intended use of cyclic barriers or would there be a better alternative to my idea?

To keep it simple, I intend to wait for 2 clients to connect. There will also be timeout conditions enforced to deal with possible failure.

huangapple
  • 本文由 发表于 2020年4月10日 22:53:33
  • 转载请务必保留本文链接:https://java.coder-hub.com/61142891.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定