posted 20 years ago
Hi,
Not sure if this has been posted before. When I try to reuse the same DatagramSocket object to listen on incoming data, the value of getLength() does not get updated!
e.g.
byte buf[] = new byte[8192];
DatagramPacket packet = new DatagramPacket(buf,buf.length);
socket.receive(packet); // 1st receive (I send 8 bytes from the other side)
// If I do packet.getLength() it returns the accurate # bytes received (i.e. 8)
socket.receive(packet); // 2nd receive (I send 30 bytes from the other side)
// If I do packet.getLength() now, it still returns me 8 instead of 30.
Has anyone encountered similar problems? I am using JDK 1.3.1