Java Documents Error in java.net.DatagramPacket
public void setLength(int length)
Set the length for this packet. The length of the packet is the number of bytes from the packet's data buffer that will be sent, or the number of bytes of the packet's data buffer that will be used for receiving data. The length must be lesser or equal to the offset plus the length of the packet's buffer.
source code for java.net.DatagramPacket
public synchronized void setLength(int length) {
if ((length + offset) > buf.length || length < 0 ||
(length + offset) < 0) {
throw new IllegalArgumentException("illegal length");
}
this.length = length;
this.bufLength = this.length;
}
"The length must be lesser or equal to the offset plus the length of the packet's buffer." is misleading. The relation should be described as "The length plus the offset should be lesser or equal to the packet's fuffer."