title: Java Multicasting: How to test on localhost?
body: <p>I am trying to implement a multicasting application in Java using a client and a multiple servers. The client would send a datagram through the <code>MultiacastSocket</code> and all servers, which would have joined a group should receive the packet. Then all servers should do something and return a unicast answer to the client. Like this: <a href="https://i.stack.imgur.com/N4kdQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N4kdQ.png" alt="enter image description here"></a></p>
  
  <p>My implementation looks like this, that the client has a MulticastSocket and the Servers just DatagramSockets. The big question for me is, how do I have to set the group-id of the servers and the portnumbers so that I can test this locally? I tried using different ports on client and servers and the same group-id <code>localhost</code>, but this doesn't work.
  Also tried <code>socket.setLoopbackMode()</code> and <code>socket.setInterface(InetAddress.getLoopbackAddress())</code>. But I got stuck somewhere and some constructive input would be great.</p>