Читати англійською Редагувати

Поділитися через


SslStream.WriteAsync Method

Definition

Overloads

WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

Asynchronously writes data to the underlying stream from a read-only byte memory range.

WriteAsync(Byte[], Int32, Int32, CancellationToken)

Asynchronously writes data to the underlying stream from the specified range of a byte array.

WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

Source:
SslStream.cs
Source:
SslStream.cs
Source:
SslStream.cs

Asynchronously writes data to the underlying stream from a read-only byte memory range.

C#
public override System.Threading.Tasks.ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, System.Threading.CancellationToken cancellationToken = default);

Parameters

buffer
ReadOnlyMemory<Byte>

The data to write to the underlying stream.

cancellationToken
CancellationToken

The token to monitor for cancellation requests.

Returns

A task that represents the asynchronous write operation.

Exceptions

Authentication has not occurred.

The write operation failed.

There is already a write operation in progress.

This object has been closed.

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

You cannot call this method until you have successfully authenticated.

The SslStream class does not support multiple simultaneous write operations.

Applies to

.NET 10 та інші версії
Продукт Версії
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1

WriteAsync(Byte[], Int32, Int32, CancellationToken)

Source:
SslStream.cs
Source:
SslStream.cs
Source:
SslStream.cs

Asynchronously writes data to the underlying stream from the specified range of a byte array.

C#
public override System.Threading.Tasks.Task WriteAsync(byte[] buffer, int offset, int count, System.Threading.CancellationToken cancellationToken);

Parameters

buffer
Byte[]

The data to write to the underlying stream.

offset
Int32

The location in buffer from which to start writing data.

count
Int32

The number of bytes to write to the underlying stream.

cancellationToken
CancellationToken

The token to monitor for cancellation requests.

Returns

A task that represents the asynchronous write operation.

Exceptions

buffer is null.

offset is less than 0.

-or-

count is less than 0.

-or-

count is greater than the length of buffer minus offset.

Authentication has not occurred.

The write operation failed.

There is already a write operation in progress.

This object has been closed.

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

You cannot call this method until you have successfully authenticated.

The SslStream class does not support multiple simultaneous write operations.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Write(Byte[], Int32, Int32).

Applies to

.NET 10 та інші версії
Продукт Версії
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1