Table of Contents

Interface ITcpStack

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

Represents a TCP stack that terminates the TCP connections carried in IP packets: it is fed packets through ProcessIncoming(IpPacket), hands the packets it produces to OnPacketSend, and gives each accepted connection as an ITcpClient through an ITcpListener.

public interface ITcpStack : IDisposable
Inherited Members

Properties

OnPacketSend

Gets or sets the callback that sends the IP packets the stack produces.

Action<IpPacket>? OnPacketSend { get; set; }

Property Value

Action<IpPacket>

Remarks

The callback owns each packet it returns from and disposes it once sent. When the callback throws, the stack disposes the packet, so the callback must not keep it; with no callback, the stack disposes its packets. The callback runs inline on whichever thread drives the stack: packet processing, a stream's read or write, or the stack's timers, so calls may overlap.

Methods

DropAllConnections()

Aborts every connection: each peer gets a reset, and each stream reads as ended. Listeners stay, and new connections are accepted afterward.

void DropAllConnections()

Listen(IPEndPoint)

Gets the listener that accepts the connections to an endpoint: that address and that port exactly.

ITcpListener Listen(IPEndPoint localEndPoint)

Parameters

localEndPoint IPEndPoint

The endpoint the connections are made to.

Returns

ITcpListener

The listener; each call for the same endpoint returns the same one until it is stopped.

Exceptions

ObjectDisposedException

The stack is disposed.

ListenAny()

Gets the listener that accepts the connections no endpoint listener takes, to any address and port.

ITcpListener ListenAny()

Returns

ITcpListener

The listener; each call returns the same one until it is stopped.

Exceptions

ObjectDisposedException

The stack is disposed.

ProcessIncoming(IpPacket)

Processes an IP packet received for the stack.

void ProcessIncoming(IpPacket ipPacket)

Parameters

ipPacket IpPacket

The packet, already parsed.

Remarks

The stack copies what it keeps: the caller still owns the packet and disposes it. A packet that is not TCP is ignored.