UDP Read/Write using different ports
<p>Is is possible to use the same DatagramSocket object to read and write using two different ports? I need to receive on port X and write on port X+1. Currently what I'm doing:</p>

<pre><code>sock = new DatagramSocket(5000);

byte[] buffer = new byte[DataAdapterFB1.HEADER_SIZE + DataAdapterFB1.MAX_DATA_BYTES];
DatagramPacket incoming = new DatagramPacket(buffer, buffer.length);
sock.receive(incoming);
</code></pre>

<p>And later:</p>

<pre><code>dp = new DatagramPacket(send.getBytes(), send.getBytes().length, DataAdapterFB1.ccuAddr, 5001);
sock.send(dp);
</code></pre>

<p>I don't see any of the output from the send packets on wireshark. </p>

<p>I have also tried:</p>

<pre><code>sock = new DatagramSocket();

byte[] buffer = new byte[DataAdapterFB1.HEADER_SIZE + DataAdapterFB1.MAX_DATA_BYTES];
DatagramPacket incoming = new DatagramPacket(buffer, buffer.length,DataAdapterFB1.localhost, 5000);
sock.receive(incoming);

dp = new DatagramPacket(send.getBytes(), send.getBytes().length, DataAdapterFB1.Addr, 5001);
sock.send(dp);
</code></pre>

<p>But it doesn't seem to work. I was able to get it to work using 2 datagramsocket objects. (Read one binds the port on the declaration, Write one does not). But want to know if I can do it with a single one.</p>