title: Android Broadcast UDP Looping
body: <p>I am currently sending out a DatagramPacket on a DatagramSocket and I receive just fine.. the problem is that I am receiving the packet I sent out.  If I call the receive twice then it times out.  Is there a way to ignore the first packet and receive the second.</p>
  
  <p>Here is my code..</p>
  
  <pre><code>            socket = new DatagramSocket(8001);
              socket.setBroadcast(true);
              socket.setReuseAddress(false);
              DatagramPacket packet = new DatagramPacket(databytes, 7,
                  getBroadcastAddress(), 8001);
              socket.send(packet);
              String localAddress = socket.getLocalAddress().toString();
  
              byte[] buf = new byte[1024];
              DatagramPacket receivepacket = new DatagramPacket(buf, buf.length);
              socket.setSoTimeout(5000);
  
              String temp = "";
              String delims = "[/]";
              while(true)
              {
                  try{
                      socket.receive(receivepacket);
                      temp = receivepacket.getAddress().toString();
                      temp = temp.split(delims)[0];
  
                      if(temp != localAddress)
                      {   
  
                      }else
                      {
                          m_IPAddress = temp;
                          break;
                      }
  
                  }catch (SocketException e){
  
                  } catch (IOException e){
                      String temp1 = e.toString();
                  }
              }
  </code></pre>