Bewerken

Share via


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.

public override System.Threading.Tasks.ValueTask WriteAsync (ReadOnlyMemory<byte> buffer, System.Threading.CancellationToken cancellationToken = default);
override this.WriteAsync : ReadOnlyMemory<byte> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask
Public Overrides Function WriteAsync (buffer As ReadOnlyMemory(Of Byte), Optional cancellationToken As CancellationToken = Nothing) As ValueTask

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

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.

public:
 override System::Threading::Tasks::Task ^ WriteAsync(cli::array <System::Byte> ^ buffer, int offset, int count, System::Threading::CancellationToken cancellationToken);
public override System.Threading.Tasks.Task WriteAsync (byte[] buffer, int offset, int count, System.Threading.CancellationToken cancellationToken);
override this.WriteAsync : byte[] * int * int * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Overrides Function WriteAsync (buffer As Byte(), offset As Integer, count As Integer, cancellationToken As CancellationToken) As Task

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