Java Multicast Sending Data, Not Receiving

前端 未结 1 404
伪装坚强ぢ
伪装坚强ぢ 2021-01-18 10:58

I am writing a class in Java which is used to greatly simplify the process of multicasting. However, I am having two big problems with it:

  1. The class sends data
1条回答
  •  被撕碎了的回忆
    2021-01-18 11:14

    I've run into similar problems before and had to ensure that the NetworkInterface was specified on the receiving side.

    SocketAddress socketAddress = new SocketAddress(groupIp, groupPort);
    NetworkInterface networkInterface = NetworkInterface.getByName(interfaceName);
    
    socket.joinGroup(socketAddress, networkInterface);
    

    Where interfaceName is one of the interface names shown when running ifconfig on Linux or Mac.

    0 讨论(0)
提交回复
热议问题