packet.setMemoryUsage(count);
dataOut.write(data, 0, count);
}
protected synchronized final Packet readPacket(DataInput dataIn, PacketReader reader) throws IOException {
Packet packet = reader.createPacket();
int length = dataIn.readInt();
packet.setMemoryUsage(length);
// read all the remaining data in one chunk ignoring the header
// TODO sometimes the length should exclude the header?
byte[] data = new byte[length];
dataIn.readFully(data);
//then splat into the internal datainput