protected boolean onRead(ClickHouseConfig config, SocketChannel sc, ClickHouseOutputStream out) throws IOException {
        final long socketTimeout = config.getSocketTimeout();
        final long startTime = socketTimeout > 0L ? System.currentTimeMillis() : 0L;

        // final ClickHousePassThruStream s = out.getUnderlyingStream();
        ByteBuffer buffer = ByteBuffer.allocate(config.getWriteBufferSize());
        byte[] bytes = buffer.array();
        int len = 0;
        while ((len = sc.read(buffer)) > 0) {
            log.trace("Receive from [%s]: [%s]", out, new String(bytes, 0, len));
            out.write(bytes, 0, len);
            buffer.clear();
            if (startTime > 0L && System.currentTimeMillis() - startTime > socketTimeout) {
                throw new SocketTimeoutException(ClickHouseUtils.format(ERROR_READ_TIMEOUT, socketTimeout));
            }
        }

        return len != -1;
    }
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