开发者

Finding the multicast IP that a datagram was sent to

开发者 https://www.devze.com 2023-03-25 22:15 出处:网络
In my application I have one MulticastSocket that joins 40 multicast IP addresses (On the same port).

In my application I have one MulticastSocket that joins 40 multicast IP addresses (On the same port).

When receiving a datagram, is there a way to find开发者_高级运维 the specific Multicast IP that a it was sent to ?

The same question about the new "DatagramChannel" (in Java 7), that also support multicasting.

Thank you very much !


In Java 1 through 6 you must create one socket per IP multicast address and then use private data to help determine the incoming address.

In the host CRT you can use IP_PKTINFO and the CMSG_* apis to determine the destination address but these have not been exposed in Java.

Java 7 brings NIO support for multicast along with SSM (RFC3768).

0

精彩评论

暂无评论...
验证码 换一张
取 消