bufferedByteCount = client.readBytes(buffer);
} else {
// Append to an earlier partial frame
- byte[] additional = client.readBytes();
- arrayCopy(additional, 0, buffer, bufferedByteCount, additional.length);
- bufferedByteCount += additional.length;
+ byte[] additional = new byte[buffer.length - bufferedByteCount];
+ int additionalLength = client.readBytes(additional);
+ arrayCopy(additional, 0, buffer, bufferedByteCount, additionalLength);
+ bufferedByteCount += additionalLength;
}
// Extract OPC packets from buffer