title: DatagramSocket() exception
body: <p>I'm newbie with android and particularly with Java programming. I'm trying to implement a very simple UDP server that should receive a broadcast UDP messages from a client from a fixed port.
  The core of the code I'm using is the following class:</p>
  
  <pre><code>private class MyDatagramReceiver extends Thread {
      private boolean bKeepRunning = true;
  
  
      public void run() {
          String message;
          message = new String("starting");
          byte[] lmessage = new byte[200];
          DatagramPacket packet = new DatagramPacket(lmessage, lmessage.length);
          updateTextView(message);
          try {
              DatagramSocket socket = new DatagramSocket(2500);
              message = new String("opened");
              updateTextView(message);
              while(bKeepRunning) {
                  socket.receive(packet);
                  message = new String(lmessage, 0, packet.getLength());                  
                  if (message != null) {
                      message = new String("received"); 
                      updateTextView(message);
                      //updateTextView(message);
                      message = null;
                  } else { 
                      message = new String("no_msg"); 
                      updateTextView(message);
                  }
              }
              if (socket != null) {
                  socket.close();
  
              }
          } catch (Exception e) {
              message = new String("problem"); 
              updateTextView(message);
              e.printStackTrace();
          }
  
  
      }
  
      public void kill() { 
          bKeepRunning = false;
      }
  
  
  }
  </code></pre>
  
  <p>as you can see I put some updateTextView(message) for debugging purposes. Particularly I should get a "starting" string when the Thread starts and than an "opened" string if the DatagramSocket is correctly opened (and no UDP message is sent from the client). Unfortunately I can't see the "opened" string, but I alway get a "problem" string that means I catch an exception.
  Furthermore I cannot read any error in the Logcat window. So I'm trying to understand what kind of exception can rise from the instruction in the try block? Could someone help me to understand what I missed. Thanks to all in advance.</p>