if (numBytesRead == -1) {
// No more bytes can be read from the channel
logger.debug("channel has reached end-of-stream");
ClientContext context = getContext(key, client);
context.closeConnection();
} else {
logger.trace("Reading " + numBytesRead + " bytes from socket");
// To read the bytes, flip the buffer
buffer.flip();
ClientContext context = getContext(key, client);