code: public ByteBuffer frameAndReturnBuffer ()
      {
          // flip the buffer which will limit it to its current position
          _buffer.flip();
  
          // then write the frame length and rewind back to the start of the
          // buffer so that all the data is available
          int count = _buffer.limit();
          _buffer.put((byte)((count >>> 24) & 0xFF));
          _buffer.put((byte)((count >>> 16) & 0xFF));
          _buffer.put((byte)((count >>>  8) & 0xFF));
          _buffer.put((byte)((count >>>  0) & 0xFF));
          _buffer.rewind();
  
          return _buffer;
      }
docs: Writes the frame length to the beginning of our buffer and returns
  it for writing to the appropriate channel. This should be followed
  by a call to {@link #resetFrame} when the frame has been written.