Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Getting the multicast address from a multicast DatagramPacket received

I'm building an application that creates a multicast socket

MulticastSocket mcDataListener = new MulticastSocket(8004);

and then joins a few multicast groups on the same interface.

mcDataListener.joinGroup(mcsocketAddr, listNetIntfc);

For example, it joins 225.1.1.1 and 225.1.1.2 on the same listNetIntfc.

The application works fine receiving multicast packets addressed to these two MC groups.

The problem I am having is that I can't find a way to identify to which MC group the DatagramPacket received belongs.
The DatagramPacket.getData() method returns the data following the IP Header (20 bytes) and the UDP Header (8 bytes).
The Destination Address with the multicast address is in the IP Header section of the packet, which is not available from the
DatagramPacket.

Appreciate any suggestion of how to resolve this problem.

Comments

Post Details

Added on Feb 28 2025
0 comments
56 views