1

I want to check if a device can join a certain multicast group or not. I am using the code snippet below. The problem is I never got any exception even if the multicast group("239.253.0.1") is not available. It seems it can always join the group successfully and I can never catch any exception. When I use wireshark to capture the packets, however, there is no such igmp packets. Why?

try{
    mcs = new MulticastSocket(1025);
    group = InetAddress.getByName("239.253.0.1");
    mcs.joinGroup(group);
    Log.d(TAG,"join the group successfully"); //I can always get the successful msg
}catch(IOException e) { 
    e.printStackTrace();
} finally{ 
     if(mcs != null) {
        try{
         mcs.leaveGroup(group);
         mcs.close();                            
        } catch(IOException e) {
                e.printStackTrace();
        }
      } 
}
mathieu
  • 29
  • 3
  • Define 'multicast group ... is not available'. – user207421 Apr 18 '17 at 03:38
  • Hi EJP, 239.253.0.1 is a given Class D IP address and I just want to use those code above to check if my device can join this group or not. In my local network, the address 239.253.0.1 is not available at this point, so I am expecting an exception. The problem is I never catch an exception. – mathieu Apr 18 '17 at 04:38
  • The problem is that you still haven't defined what 'not available' means, despite my request. You've just repeated it. – user207421 Apr 18 '17 at 05:13
  • Sorry, I mean there is no multicast group named 239.253.0.1 in my local network. If it has joined such a group, wireshark should have captured an corresponding IGMP Membership Report message, right? – mathieu Apr 18 '17 at 05:25
  • There is a multicast group named 239.253.0.1 in every network. Yes you should see an IGMP message, unless the host had already joined. – user207421 Apr 18 '17 at 05:34
  • Thanks EJP! Actually, I have tried to leave the group after invoking joinGroup. I still can't capture such IGMP message. – mathieu Apr 18 '17 at 06:34
  • Cannot reproduce. Your *real* question appears to be 'why aren't I seeing the IGMP messages'. Maybe you aren't sniffing the right interface. – user207421 Apr 18 '17 at 08:15
  • @EJP You said there is a multicast group named 239.253.0.1 in every network. I am wondering if there is any official document which describes this? – mathieu Jul 05 '17 at 01:46

0 Answers0