@Override
    public long write(ByteBuffer[] srcs, int offset, int length) throws IOException {
        if ((offset < 0) || (length < 0) || (offset > srcs.length - length))
            throw new IndexOutOfBoundsException();
        int totalWritten = 0;
        int i = offset;
        while (i < offset + length) {
            if (srcs[i].hasRemaining() || hasPendingWrites()) {
                int written = write(srcs[i]);
                if (written > 0) {
                    totalWritten += written;
                }
            }
            if (!srcs[i].hasRemaining() && !hasPendingWrites()) {
                i++;
            } else {
                // if we are unable to write the current buffer to socketChannel we should break,
                // as we might have reached max socket send buffer size.
                break;
            }
        }
        return totalWritten;
    }
Writes a sequence of bytes to this channel from the subsequence of the given buffers.

@param srcs The buffers from which bytes are to be retrieved
@param offset The offset within the buffer array of the first buffer from which bytes are to be retrieved; must be non-negative and no larger than srcs.length.
@param length - The maximum number of buffers to be accessed; must be non-negative and no larger than srcs.length - offset.
@return returns no.of bytes written , possibly zero.
@throws IOException If some other I/O error occurs
clients/src/main/java/org/apache/kafka/common/network/SslTransportLayer.java