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!

IGMP - how can I receive the packet?

843790Dec 2 2009 — edited Feb 2 2010
Hello All,
I have a question:
I need to catch the join/leave igmp package.

As I understand, it is not hard to write a java program that sends such request:

for example:

ia = InetAddress.getByName("224.0.0.0");
MulticastSocket ms = new MulticastSocket(5000);
ms.joinGroup(ia);

Now, if there is an IGMP server running (I have one which I didn't write...) and I ask it to send packets to 224.0.0.0 port 5000,
the server will get the join group request and will start to send the packets.

What I can not figure out is how to catch by a java program the join request.

i.e.
I would like to write a java program that will open a socket and when the client ms.joinGroup(ia) line will be executed I will get the IGMP package and will be able to parse it.


If I understand correctly, the join message is being sent to the ip 224.0.0.22 which is a reserved ip for IGMP. However, I don't understand how to listen to that address as:

a) there is no port for that address
b) this address is reserved and therefor, when I try to open a DatagramSocket with that address (and a port... I must give a port because of the DatagramSocket constructor. Therefor, I gave for example port 5000... but it didn't help): I get Exception"java.net.BindException: Cannot assign requested address: Cannot bind"


Can someone please help me?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 2 2010
Added on Dec 2 2009
8 comments
492 views