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
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- IAsyncEnumerable<ITcpClient>
The accepted connections; the caller owns each and disposes it.
Exceptions
- OperationCanceledException
cancellationTokenwas canceled.
AcceptAsync(CancellationToken)
Accepts the next connection that completes its handshake.
ValueTask<ITcpClient> AcceptAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe 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
cancellationTokenwas 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()