有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何计算加入多播socket的客户端?

我正在用MulticastSocket编程一个聊天,我会计算加入这个聊天的客户端的数量

try (MulticastSocket clientSocket = new MulticastSocket(PORT)) {
    clientSocket.joinGroup(address);

MulticastSocket是否有此功能


共 (1) 个答案

  1. # 1 楼答案

    这在技术上是不可能的。按照IP多播协议的工作方式,端点不知道多播组中还有哪些其他端点

    正如this Wikipedia page所描述的:

    IP multicast operation does not require an active source to know about the receivers of the group. The multicast tree construction is receiver driven and is initiated by network nodes which are close to the receivers. IP multicast scales to a large receiver population. The IP multicast model has been described by Internet architect Dave Clark as, "You put packets in at one end, and the network conspires to deliver them to anyone who asks."