Interface IListener<T>
- Namespace
- IceRpc.Transports
- Assembly
- IceRpc.dll
A listener listens for connection requests from clients.
public interface IListener<T> : IAsyncDisposable
Type Parameters
TThe connection type.
- Inherited Members
Remarks
The IceRPC core and the Slic transport implementation call this interface. They provide the following guarantees:
<ul><li>The <xref href="IceRpc.Transports.IListener%601.AcceptAsync(System.Threading.CancellationToken)" data-throw-if-not-resolved="false"></xref> method is never called concurrently.</li><li>The <xref href="System.IAsyncDisposable.DisposeAsync" data-throw-if-not-resolved="false"></xref> method can be called while an
<xref href="IceRpc.Transports.IListener%601.AcceptAsync(System.Threading.CancellationToken)" data-throw-if-not-resolved="false"></xref> call is in progress. It can be called multiple times but not concurrently.</li></ul>
Properties
TransportAddress
Gets the transport address of this listener. That's the address a client would connect to.
TransportAddress TransportAddress { get; }
Property Value
- TransportAddress
The transport address.
Methods
AcceptAsync(CancellationToken)
Accepts a new connection.
Task<(T Connection, EndPoint RemoteNetworkAddress)> AcceptAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenA cancellation token that receives the cancellation requests.
Returns
- Task<(T Connection, EndPoint RemoteNetworkAddress)>
A task that completes successfully with the accepted connection and network address of the client.
Remarks
The returned task can also complete with one of the following exceptions:
- IceRpcException if the transport reported an error.
- OperationCanceledException if cancellation was requested through the cancellation token.
Exceptions
- ObjectDisposedException
Thrown if the connection has been disposed.