Table of Contents

Interface ITcpListener

Namespace
VpnHood.Net.TcpStack.Abstractions
Assembly
VpnHood.Net.TcpStack.Abstractions.dll

Represents a listener that accepts the connections an ITcpStack completes, the way TcpListener does for sockets.

public interface ITcpListener : IDisposable
Inherited Members

Methods

AcceptAllAsync(CancellationToken)

Accepts connections as they complete their handshake, until the listener is stopped.

IAsyncEnumerable<ITcpClient> AcceptAllAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

IAsyncEnumerable<ITcpClient>

The accepted connections; the caller owns each and disposes it.

Exceptions

OperationCanceledException

cancellationToken was canceled.

AcceptAsync(CancellationToken)

Accepts the next connection that completes its handshake.

ValueTask<ITcpClient> AcceptAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

ValueTask<ITcpClient>

A task whose result is the accepted connection, which the caller owns and disposes.

Exceptions

OperationCanceledException

cancellationToken was canceled.

InvalidOperationException

The listener is stopped.

Stop()

Stops the listener: ends its accepts and closes the connections in its queue; a handshake under way for it is closed when it completes. Connections already accepted stay open.

void Stop()