JRockit 1.4.2_08 - DatagramPacket gets its address overwriten when a new packet arrives from another address. (Doc ID 776925.1)

Last updated on NOVEMBER 05, 2016

Applies to:

Oracle JRockit / JRockit / 1.4.2_08
Information in this document applies to any platform

Goal

When receiving DatagramPackets the address of the sender is saved as a reference to the address in the DatagramSocket
instead of being copied, so when a new DatagramPacket arrives from a different address the address of the first packet
will be overwritten.
Here is an example:

DatagramSocket serverSocket = new DatagramSocket(port);
while(true){
    byte[] buf = new byte[MAX_PACKET_SIZE];
    DatagramPacket packet = new DatagramPacket(buf, buf.length);
    serverSocket.receive(packet);
    DoSomethingWithData(packet);
}

Solution

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms