private int select(long timeoutMs) throws IOException {
        if (timeoutMs < 0L)
            throw new IllegalArgumentException("timeout should be >= 0");

        if (timeoutMs == 0L)
            return this.nioSelector.selectNow();
        else
            return this.nioSelector.select(timeoutMs);
    }
Check for data, waiting up to the given timeout.

@param timeoutMs Length of time to wait, in milliseconds, which must be non-negative
@return The number of keys ready
clients/src/main/java/org/apache/kafka/common/network/Selector.java