Table of Contents

Interface IDuplexConnection

Namespace
IceRpc.Transports
Assembly
IceRpc.dll

Represents a transport connection created by a duplex transport.

public interface IDuplexConnection : IDisposable
Inherited Members

Remarks

Both the IceRPC core and the Slic transport implementation use this interface. They provide the following guarantees:

Methods

ConnectAsync(CancellationToken)

Connects this connection.

Task<TransportConnectionInformation> ConnectAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

A cancellation token that receives the cancellation requests.

Returns

Task<TransportConnectionInformation>

A task that completes successfully with transport connection information when the connection is established. This task can also complete with one of the following exceptions:

Exceptions

InvalidOperationException

Thrown if this connection is connected, connecting or if a previous connection attempt failed.

ObjectDisposedException

Thrown if the connection is disposed.

ReadAsync(Memory<byte>, CancellationToken)

Reads data from the connection.

ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken)

Parameters

buffer Memory<byte>

A buffer that receives the data read from the connection.

cancellationToken CancellationToken

A cancellation token that receives the cancellation requests.

Returns

ValueTask<int>

A value task that completes successfully with the number of bytes read into buffer. This number is 0 when no data is available and the peer has called ShutdownWriteAsync(CancellationToken); otherwise, it is always greater than 0. This value task can also complete with one of the following exceptions:

Exceptions

ArgumentException

Thrown if buffer is empty.

InvalidOperationException

Thrown if the connection is not connected or if a read operation is already in progress.

ObjectDisposedException

Thrown if the connection is disposed.

ShutdownWriteAsync(CancellationToken)

Shuts down the write side of the connection to notify the peer that no more data will be sent.

Task ShutdownWriteAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

A cancellation token that receives the cancellation requests.

Returns

Task

A task that completes successfully when the shutdown completes successfully. This task can also complete with one of the following exceptions:

Exceptions

InvalidOperationException

Thrown if the connection is not connected, already shut down or shutting down, or a write operation is in progress.

ObjectDisposedException

Thrown if the connection is disposed.

WriteAsync(ReadOnlySequence<byte>, CancellationToken)

Writes data over the connection.

ValueTask WriteAsync(ReadOnlySequence<byte> buffer, CancellationToken cancellationToken)

Parameters

buffer ReadOnlySequence<byte>

The buffer containing the data to write.

cancellationToken CancellationToken

A cancellation token that receives the cancellation requests.

Returns

ValueTask

A value task that completes successfully when the data is written successfully. This value task can also complete with one of the following exceptions:

Exceptions

ArgumentException

Thrown if buffer is empty.

InvalidOperationException

Thrown if the connection is not connected, already shut down or shutting down, or a write operation is already in progress.

ObjectDisposedException

Thrown if the connection is disposed.