一款简单易用的基础网络通讯组件库。

TransportStreamWriteAsync(Byte, Int32, Int32, CancellationToken) 方法

Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

Definition

命名空间: TouchSocket.Sockets
程序集: TouchSocket (在 TouchSocket.dll 中) 版本:4.0.0-beta.143+5fcca7a4e70968794985dc3793adc50531308be6
C#
public override Task WriteAsync(
	byte[] buffer,
	int offset,
	int count,
	CancellationToken cancellationToken
)

参数

buffer  Byte
The buffer to write data from.
offset  Int32
The zero-based byte offset in buffer from which to begin copying bytes to the stream.
count  Int32
The maximum number of bytes to write.
cancellationToken  CancellationToken
The token to monitor for cancellation requests. The default value is None.

返回值

Task
A task that represents the asynchronous write operation.

异常

ArgumentNullExceptionbuffer is .
ArgumentOutOfRangeExceptionoffset or count is negative.
ArgumentExceptionThe sum of offset and count is larger than the buffer length.
NotSupportedExceptionThe stream does not support writing.
ObjectDisposedExceptionThe stream has been disposed.
InvalidOperationExceptionThe stream is currently in use by a previous write operation.

参见