title: Java: send repeatedly from same UDP port or specify localport for UDP Socket.send()
body: <p>Is it possible to either use the same port over multiple socket.send() or specify a port when creating a DatagramSocket? If so how. I am attempting hole-punching and need to listen from the port that is used and I cannot change the port the client is sending from.</p>
  
  <pre><code>try {
          DatagramSocket dSocket = new DatagramSocket();
          InetAddress serverAddr = InetAddress.getByName(TARGETIP)
          int msg_len = currentMsg.length();
          byte[] message = currentMsg.getBytes();
          DatagramPacket dPacket = new DatagramPacket(message,msg_len,serverAddr,3222);
          dSocket.send(dPacket);
          updateConversationHandler.post(new systemUIUpdate("UDP Packet from " + dSocket.getLocalPort()));
  }
  catch (Exception e){
      e.getMessage();
      e.printStackTrace();
  }
  </code></pre>
  
  <p>Every time this is run via an eventhandler dSocket.getLocalPort() shows a different port.</p>