This discussion is archived
1 Reply Latest reply: Oct 9, 2012 7:14 PM by EJP RSS

multicast socket doesn't work when using JDK 7 on Mac

967231 Newbie
Currently Being Moderated
I have a code about multicast sending and receiving. It can work on Mac using JDK 6. However, when I change to use JDK 7, it can't work correctly.

The code is like this:
final InetAddress group = InetAddress.getByName("228.2.3.4");
final MulticastSocket socket = new MulticastSocket(2012);

socket.setReuseAddress(true);
socket.joinGroup(group);

final int length = 8 * 1024;
final byte[] bytes = new byte[length];
final DatagramPacket packet = new DatagramPacket(bytes, length);

while(true) 
{                              
     socket.receive(packet);
        ...
}
...
Using JDK 7 to compile and run it, it can't work when VMware running. But if using JDK 6, it can work even though VMware is running.

Besides, I try to use WireShark to monitor the adapter. And I found WireShark can see all multicast packets sent and received when using JDK 7 to run my program. But the multicast socket can't receive any.

Anyone has any idea about it? Thanks for your help.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points