Table of Contents

Interface IProtocolConnection

Namespace
IceRpc
Assembly
IceRpc.dll

Represents a connection for a Protocol. It is the building block for ClientConnection, ConnectionCache and the connections created by Server. Applications can use this interface to build their own custom client connection and connection cache classes.

public interface IProtocolConnection : IInvoker, IAsyncDisposable
Inherited Members
Extension Methods

Remarks

The disposal of the protocol connection aborts invocations, cancels dispatches and disposes the underlying transport connection without waiting for the peer. To wait for invocations and dispatches to complete, call ShutdownAsync(CancellationToken) first. If the configured dispatcher does not complete promptly when its cancellation token is canceled, the disposal can hang.

Methods

ConnectAsync(CancellationToken)

Establishes the connection to the peer.

Task<(TransportConnectionInformation ConnectionInformation, Task ShutdownRequested)> ConnectAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A cancellation token that receives the cancellation requests.

Returns

Task<(TransportConnectionInformation ConnectionInformation, Task ShutdownRequested)>

A task that provides the TransportConnectionInformation of the transport connection and a task that completes when the connection itself wants to be shut down then disposed by the caller. This can happen when the peer initiates a shutdown, when the connection is inactive for too long (see InactivityTimeout), when the connection detects a protocol violation, or when the connection gets an error from its transport connection. This task can also complete with one of the following exceptions:

Exceptions

InvalidOperationException

Thrown if this method is called more than once.

ObjectDisposedException

Thrown if this connection is disposed.

ShutdownAsync(CancellationToken)

Gracefully shuts down the connection.

Task ShutdownAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A cancellation token that receives the cancellation requests.

Returns

Task

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

Exceptions

InvalidOperationException

Thrown if ConnectAsync(CancellationToken) did not complete successfully prior to this call, or if this method is called more than once.

ObjectDisposedException

Thrown if this connection is disposed.

See Also