Table of Contents

Class TcpSubscriptionTransport

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

The engine's own listener: an asynchronous Socket, the TYP2 preamble, u32 len framing, and no ASP.NET Core anywhere.

public sealed class TcpSubscriptionTransport : ISubscriptionTransport
Inheritance
TcpSubscriptionTransport
Implements
Inherited Members

Remarks

Who it is for. Native and Unity clients, server-to-server links, bots, tests, and deployments that embed the engine and never host HTTP (design/Subscriptions/04-transport.md § 4). A browser needs the WebSocket adapter, which is a separate package precisely so that everything HTTP — TLS policy, origin checks, upgrade limits — stays out of this assembly (AC-19).

It binds loopback unless told otherwise. Nothing here authenticates a peer: HELLO's token is opaque and reaches the application's admission hook unexamined. The previous implementation bound every interface with no authentication, which is the one default that cannot be walked back once a sample has been copied.

What it owns and what it refuses to own. Bytes, framing, TLS, the accept loop and the close. Not a single protocol decision: the preamble is the one comparison it makes, and it is a transport-level version check the wire itself defines as never being a KICK (design/Subscriptions/03-wire-protocol.md § 12 W31). Everything else — the handshake, admission, the caps, the close codes — happens behind Accept(ISubscriptionLink, in LinkInfo).

Starting it: after runtime.Start(), runtime.StartSubscriptionTransport(new TcpSubscriptionTransport(new TcpSubscriptionOptions { Port = 9100 })); stop it with StopAsync() before shutting the runtime down.

Constructors

TcpSubscriptionTransport(TcpSubscriptionOptions)

Creates the listener. Nothing is bound until Start(ISubscriptionAcceptor).

public TcpSubscriptionTransport(TcpSubscriptionOptions options = null)

Parameters

options TcpSubscriptionOptions

Where to listen and how, or null for the loopback defaults.

Properties

BoundEndPoint

Where the listener actually bound, which is how an ephemeral port (Port = 0) is discovered. null before Start(ISubscriptionAcceptor).

public IPEndPoint BoundEndPoint { get; }

Property Value

IPEndPoint

ConnectionCount

How many connections are being served right now, the ones still exchanging their preamble included.

public int ConnectionCount { get; }

Property Value

int

Methods

Start(ISubscriptionAcceptor)

Begins listening, handing every connection to acceptor.

public void Start(ISubscriptionAcceptor acceptor)

Parameters

acceptor ISubscriptionAcceptor

The engine's acceptor. It is the only engine surface a transport ever calls into to create a connection.

Remarks

Called once, from the runtime's start path. A transport that cannot bind throws here, where the failure reaches the host as a start failure rather than as a server that is running and unreachable.

StopAsync()

Stops listening and closes what is still connected.

public ValueTask StopAsync()

Returns

ValueTask

A task that completes when no link remains and no receive loop is running.

Remarks

Every live link is closed with GoingAway and each connection is told through OnClosed(ushort, Exception), so a transport that returns without doing so leaves session rows the engine will never reclaim.