title: Send and receive datagram packet
body: <p>sorry for my bad english. I have to send and receive data from phone to radio using bluetooth pan interface on android. This is the code I've implemented to send, I've made it into the function DoInBackground() of AsyncTask:</p>
  
  <pre><code> try
             {
  
              ds = new DatagramSocket();
              byte buf[] = "Ciao".getBytes();
              DatagramPacket msg = new DatagramPacket(buf, buf.length, InetAddress.getByName(add), p);
  
              ds.send(msg);
  
          }
  </code></pre>
  
  <p>and it works perfectly. Now I have to wait 100 seconds the answer of the radio. I decide to implement it with this code:</p>
  
  <pre><code>try
         {
             ds.setSoTimeout(10000);
  
             while(true)
             {
                 try
                 {
                     ds.receive(dp);
                 }
                 catch (IOException e)
                 {
                     e.printStackTrace();
                 }
             }
  
  
  
         }
         catch (IOException e)
         {
  
         }
  </code></pre>
  
  <p>but there are three questions:
  1. I need to receive the packet at 192.168.11.2 and 1234 port, but when I declared datagramsocket I set it void, because if i put port and address, send code doesn't work;
  2. How can I manage the packet I've received by the radio? I don't need to use address and port bytes;
  3. Why have I put the timeout before the loop?</p>
  
  <p>Thank you for the answers.</p>