private long readBuffer(SelectionKey key, int offset) {
        long numRead = 0;
        SocketChannel socketChannel = (SocketChannel) key.channel();
        while (buffer[offset].hasRemaining()) {
            enterLoopNIO.inc();
            try {
                numRead += socketChannel.read(buffer, offset, 1);
            } catch (IOException e) {
                log.severe("error reading buffer");
                numRead = -1;
            }
            if (numRead == -1) break;
        }
        try {
            if (numRead == -1) {
                this.keepDataTrack.remove(socketChannel);
                log.info("Connection closed by: " + socketChannel.getRemoteAddress());
                socketChannel.close();
                onRemoveClient(key);
                key.cancel();
            }
        } catch (IOException e) {
            log.severe("error reading buffer negative value");
        }

        return numRead;
    }