code: private void readHeaderFromBuffer(final ByteBuffer buffer) {
      int toRead = MIN_RECV_PACKET - headerOffset;
      int available = buffer.remaining();
      toRead = Math.min(toRead, available);
      getLogger().debug("Reading %d header bytes", toRead);
      buffer.get(header, headerOffset, toRead);
      headerOffset += toRead;
    }
docs: Read the header bytes from the incoming {@link ByteBuffer}.
  
  @param buffer the buffer to read from.