title: Sending multicast UDP and waiting for responses
body: <p>In my network I have several devices (linux, c++) and one android smartphone.<br>
  Now, in order to recognize the devices in the network I am sending out a multicast udp packet from the android smartphone with the following code:</p>
  
  <pre><code>public class SSDPSocket {
      SocketAddress mSSDPMulticastGroup;
      MulticastSocket mSSDPSocket;
      InetAddress broadcastAddress;
  
      public SSDPSocket() throws IOException {
          mSSDPSocket = new MulticastSocket(55325);
          broadcastAddress = InetAddress.getByName(SSDPConstants.ADDRESS);
          mSSDPSocket.joinGroup(broadcastAddress);
      }
  
      public void send(String data) throws IOException {
          DatagramPacket dp = new DatagramPacket(data.getBytes(), data.length(), broadcastAddress, SSDPConstants.PORT);
          mSSDPSocket.setTimeToLive(2);
          mSSDPSocket.send(dp);
      }
  
      public void receive() {
          // TODO: Implement!
      }
  }
  </code></pre>
  
  <p>The address to which I am sending the udp packet is <code>239.255.255.250</code>, port is <code>1900</code>.
  This works fine, and I am able to receive the packets on my clients.<br>
  Now I have problems to implement the receive method. In this method I want to receive respones from <strong>all</strong> my special devices in the network. First the clients have to respond to the sender address (the ip of my smartphone) right? Then I would have some kind of loop in the <code>receive()</code>method where I can receive incomming udp respones right? </p>
  
  <p>Do I have to open a new <code>DatagramSocket</code> for this? Or can I use the already opened <code>MulticastSocket</code> for responses? In the examples I found everybody is using the opened <code>MulticastSocket</code> for response, but how should this work since the <code>MulticastSocket</code> is bound to <code>239.255.255.250</code>? </p>