I was working with a MulticastSocket and when ever I tried to join a group, it would never work when I was running the group on the "localhost" ip. However, I found this article http://lycog.com/programming/multicast-programming-java/ that stated the range should be between 224.0.0.1 and 239.255.255.254. When I made an InetAddress out of that IP and joined the group it worked. Please explain why this is necessary.
Example:
InetAddress group = InetAddress.getByName("localhost");
int port = 8888;
MulticastSocket socket = new MulticastSocket(port);
socket.joinGroup(group);
//throws
Unable to connect to host:localhost on port:8888
java.net.SocketException: Not a multicast address
Example that works:
InetAddress group = InetAddress.getByName("224.0.0.1");
int port = 8888;
MulticastSocket socket = new MulticastSocket(port);
socket.joinGroup(group);