MsQuicListener Class

Listens for QUIC connections.

public sealed class MsQuicListener : IAsyncDisposable
Implements

Properties

NameDescription
IsSupportedGets a value indicating whether MsQuic is available, see MsQuicLibrary.
LocalEndPointGets the address the listener listens on, with the port it picked when the options set port 0.

Gets a value indicating whether MsQuic is available, see MsQuicLibrary.

public static bool IsSupported { get; }

Property value

bool

LocalEndPoint

MsQuicListener.cs

Gets the address the listener listens on, with the port it picked when the options set port 0.

public IPEndPoint LocalEndPoint { get; }

Property value

IPEndPoint

Methods

NameDescription
AcceptConnectionAsync(CancellationToken)Waits for the next connection whose handshake completed.
DisposeAsync()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
ListenAsync(MsQuicListenerOptions, CancellationToken)Starts listening.

AcceptConnectionAsync(CancellationToken)

MsQuicListener.cs

Waits for the next connection whose handshake completed.

net10.0

public ValueTask<MsQuicConnection> AcceptConnectionAsync(CancellationToken cancellationToken = default)

net11.0

public ValueTask<MsQuicConnection> AcceptConnectionAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

ValueTask<MsQuicConnection>

Exceptions

ObjectDisposedException
The listener is disposed.

DisposeAsync()

MsQuicListener.cs

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

net10.0

public ValueTask DisposeAsync()

net11.0

public ValueTask DisposeAsync()

Returns

ValueTask A task that represents the asynchronous dispose operation.

ListenAsync(MsQuicListenerOptions, CancellationToken)

MsQuicListener.cs

Starts listening.

public static ValueTask<MsQuicListener> ListenAsync(MsQuicListenerOptions options, CancellationToken cancellationToken = default)

Parameters

options MsQuicListenerOptions
cancellationToken CancellationToken

Returns

ValueTask<MsQuicListener>

Exceptions

PlatformNotSupportedException
MsQuic is not available.
MsQuicException
The listener could not start, for instance because the address is in use.