@Override
    public void close() throws IOException {
        final SelectionKey key = this.selectionKey;
        if (!key.isValid()) {
            return;
        }

        try {
            log.trace("Closing selector...");
            if (key.selector().isOpen()) {
                key.selector().close();
            }
        } finally {
            log.trace("Closing channel...");
            if (key.channel().isOpen()) {
                key.channel().close();
            }

            log.trace("Closing selection key...");
            log.trace("Release attached object: [%s]", key.attach(null));
            key.cancel();
        }
    }
Reads byte from socket input buffer.

@param config non-null configuration
@param sc     socket channel
@param out    output stream
@return true if the read was a success; false otherwise
@throws IOException
clickhouse-client/src/main/java/com/clickhouse/client/AbstractSocketClient.java