net-coroutines / org.apache.tuweni.net.coroutines / GatheringCoroutineByteChannel / tryWrite

tryWrite

abstract fun tryWrite(srcs: Array<ByteBuffer>, offset: Int = 0, length: Int = srcs.size): Long (source)

Writes a sequence of bytes to this channel from a subsequence of the given buffers, if the channel is ready for writing.

Parameters

srcs - The buffers from which bytes are to be retrieved.

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.

length - The maximum number of buffers to be accessed; must be non-negative and no larger than srcs.length - offset.

Exceptions

IndexOutOfBoundsException - If the preconditions on the offset and length parameters do not hold.

NonWritableChannelException - If this channel was not opened for writing.

ClosedChannelException - If the channel is closed.

AsynchronousCloseException - If another thread closes this channel while the write operation is in progress.

ClosedByInterruptException - If another thread interrupts the current thread while the write operation is in progress, thereby closing the channel and setting the current thread's interrupt status.

IOException - If some other I/O error occurs.

Return
The number of bytes written, possibly zero.