UDP code need to rewrite
<p>Wanted to implement this code into one of the class, not main class, it will need try and catch for IOException, how do I place it?</p>

<p>when call <code>sendUPD(valueData);</code> it will send string to the function.</p>

<pre><code>private boolean Notconnected = true;

private void sendUDP(String s){
 if(Notconnected){
   DatagramSocket datgramSocket = new DatagramSocket(4455); //&lt;--- try catch
   Notconnected = false;
  }
  try {

   byte[] buf = new byte[512];

        DatagramPacket incomingPacket = new DatagramPacket(buf, buf.length);
        datgramSocket.receive(incomingPacket);

        //What did we just receive?
        //String s = new String(incomingPacket.getData(),0,incomingPacket.getLength());

        if(!(s.equals("quit"))){
         String responseString = s;
   buf = responseString.getBytes("UTF-8");

         InetAddress address = incomingPacket.getAddress();
         int port = incomingPacket.getPort();

         DatagramPacket outgoingPacket = new DatagramPacket(buf, buf.length, address, port);

         datgramSocket.send(outgoingPacket);
   } 
  } catch (IOException e) { }
 }
</code></pre>
