code: public void send(Command command) {
      logger.finest(command.toString());
      byte[] payload = command.toByteArray();
      int totalSize = payload.length + 1; // increment 1 for message type
  
      ByteBuffer outMessageSize = encodeMessageSize(totalSize);
  
      // create the message
      ByteBuffer buffer = ByteBuffer.allocateDirect(prefix.length
                                                    + outMessageSize.position() + 1 + payload.length);
      buffer.put(prefix, 0, prefix.length);
      outMessageSize.flip();
      buffer.put(outMessageSize);
      buffer.put((byte) 1);
      buffer.put(payload);
  
      // Log what is being sent.
      logger.finest("SEND: " + command);
  
      requests.add(buffer);
      monitor.modify(socketChannel, this, SelectionKey.OP_READ | SelectionKey.OP_WRITE);
    }
docs: Queues up an STP/1 message sent from another thread and wakes up selector to register it to the
  key.
  
  @param command to add to the request queue