public void sendReply(ByteBuffer reply) throws IOException {
    // for binary set the response opCode
    if (protocol == Protocol.BINARY) {
      reply.rewind();
      reply.put(POSITION_OPCODE, buffer.get(POSITION_OPCODE));
      reply.putInt(POSITION_OPAQUE, buffer.getInt(POSITION_OPAQUE));
      if (ConnectionHandler.getLogger().finerEnabled()) {
        ConnectionHandler.getLogger()
            .finer("sending reply:" + reply + " " + Command.buffertoString(reply));
      }
    }
    SocketChannel channel = socket.getChannel();
    if (channel == null || !channel.isOpen()) {
      throw new IllegalStateException("cannot write to channel");
    }
    channel.write(reply);
  }
Returns an initialized byteBuffer for sending the reply

@param size size of ByteBuffer
@return the initialized response buffer
geode-memcached/src/main/java/org/apache/geode/internal/memcached/RequestReader.java