多播的替代方案

发布于 2024-12-06 12:36:51 字数 204 浏览 3 评论 0原文

我目前正在开发一个服务器(使用Java),它必须经常(每10-30秒)向多个客户端(10-100)发送几个字节。起初,我想到使用 UDP 多播数据报(java.net.MulticastSocket),但我认为这不是一个好的解决方案,因为大多数路由器对多播的支持很差。

所以我想知道如果我通过单播将所有数据直接发送到主机是否是个好主意,或者您知道有什么更优雅/流量更少的方法吗?

I'm currently developing a server (using Java) that has to send quite often (every 10-30 seconds) a few bytes to multiple clients (10 - 100). At first, I thought of using UDP multicast datagrams (java.net.MulticastSocket), but I thought of this not being a good solution because of the bad support for multicast on most routers.

So I'm wondering if it would be a good idea if I sent all data directly to the hosts via unicast or do you know of anything more elegant/with less traffic?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蓝天白云 2024-12-13 12:36:51

使用 JMS 有很多优点,但其中大多数都使用 TCP,您也可以。即使在低带宽网络上,每 10-30 秒几个字节对于几百个客户端来说也很小。

假设您每 10 秒向 100 个客户端发送一条 100 字节的消息,即每秒 1000 字节或 8Kbits/秒。即使是 3G 网络也能轻松支持此带宽。也就是说,您可以使用智能手机来完成此操作。 ;)

最简单的方法可能是从每个客户端建立一个 tcp 连接,服务器根据需要发送更新消息。

There are many advantages in using JMS, but most of these use TCP and so could you. A few bytes every 10-30 seconds to a few hundred clients is small even on low bandwidth networks.

Say you send a 100 bytes message to 100 clients every 10 seconds, That 1000 bytes per second or 8Kbits/second. Even 3G networks will support this bandwidth easily. i.e. you could do this with a smart phone. ;)

The simplest approach may be to have a tcp connection from each client which the server sends update messages as required.

与往事干杯 2024-12-13 12:36:51

您是否考虑过使用消息队列,例如 Active MQ?它们有一个很好的特点,即您将消息写入队列一次,并且可以有任意数量的读者来读取队列。

Have you considered using a message queue such as Active MQ? These have the nice characteristic that you write the message once to the queue and you can have as many readers as you like reading the queue.

我不咬妳我踢妳 2024-12-13 12:36:51

您还可以使用基于gossip应用程序级多播协议。例如,NeEM 将轻松扩展到 100 个目的地,同时提供类似于 MulticastSocket 的接口并仅使用 TCP/IP,因此与不太理想的网络设置兼容。

You can also use a gossip-based application-level multicast protocol. For instance, NeEM will scale easily to 100 destinations while providing an interface similar to MulticastSocket and using just TCP/IP, thus being compatible with less than optimal network setups.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文