Moongate.Network
0.6.0
Prefix Reserved
See the version list below for details.
dotnet add package Moongate.Network --version 0.6.0
NuGet\Install-Package Moongate.Network -Version 0.6.0
<PackageReference Include="Moongate.Network" Version="0.6.0" />
<PackageVersion Include="Moongate.Network" Version="0.6.0" />
<PackageReference Include="Moongate.Network" />
paket add Moongate.Network --version 0.6.0
#r "nuget: Moongate.Network, 0.6.0"
#:package Moongate.Network@0.6.0
#addin nuget:?package=Moongate.Network&version=0.6.0
#tool nuget:?package=Moongate.Network&version=0.6.0

Moongate.Network
MoongateTcpClient.ConnectConfiguredAsync accepts TcpClientOptions to prepare
a transport stream and install callbacks before reception starts. For example,
ConnectionPipeline.PrepareStreamAsync can authenticate an SslStream, while
ConfigureClient subscribes to receive events before the first byte is delivered.
The preparation token covers the connection/setup deadline and caller cancellation.
The returned stream must own its input stream; if preparation throws, dispose any
wrapper created before throwing. After successful setup, the client owns both the
prepared stream and socket. Configuration failure also releases both resources.
The existing ConnectAsync overload remains available with its original behavior.
Use MoongateTcpServer.CreateConfigured(endpoint, options) for the corresponding
accepted-connection preparation path. TcpServerOptions bounds both admitted
connections and concurrent preparation operations; excess sockets close immediately.
A slow TLS handshake does not block accepting another connection. Server stop cancels
preparation, drains the admitted setups and owns their socket cleanup before a restart.
Preparation callbacks must observe cancellation. The legacy constructor retains its
original admission behavior; preparation callbacks are enabled by the configured entry points.
Standalone asynchronous TCP transport with framing, middleware, and per-connection pipelines for .NET applications.
Installation
Requires .NET 10. Use the package version available in your configured NuGet feed.
dotnet add package Moongate.Network
Features
- Asynchronous TCP server and client APIs.
- Access to the bound server endpoint, including an automatically assigned port.
- Configurable framing, transport codecs, and middleware.
- Per-connection pipelines for application-specific connection handling.
Example
Start a loopback listener on an available port and stop it cleanly:
using System.Net;
using Moongate.Network.Server;
await using var server = new MoongateTcpServer(new IPEndPoint(IPAddress.Loopback, 0));
await server.StartAsync(CancellationToken.None);
if (server.Endpoint.Port == 0)
{
throw new InvalidOperationException("The listener did not bind to a port.");
}
await server.StopAsync(CancellationToken.None);
Console.WriteLine("TCP listener started and stopped.");
See the standalone TCP cookbook for a runnable framed client/server exchange, per-connection middleware and cleanup.
Dependencies and scope
This package depends on Serilog and has no dependency on other Moongate packages.
TCP is a byte stream. Configure framing for your application protocol; transport reads do not define game-packet boundaries. This library does not automatically decode Ultima Online packets or dispatch work into a game loop. Use Moongate.Network.Packets for UO packet definitions and serialization.
Abstract connection metadata
INetworkConnection exposes transport identity, completion, send/close operations and
remote endpoint metadata. Its optional LocalEndPoint property has a default interface
implementation returning null, so existing custom connection implementations do not need
a new member. MoongateTcpClient supplies its actual local endpoint.
string DescribeLocalEndpoint(Moongate.Network.Interfaces.Client.INetworkConnection connection)
{
return connection.LocalEndPoint?.ToString() ?? "Local endpoint unavailable";
}
TCP event payloads are stable copies; middleware inputs are borrowed until their
ValueTask completes. The host INetworkService contract requires decoding or
copying before its callback returns.
Keep connection ownership separate from game sessions; the host's IConnectionService
and INetworkService contracts live in Moongate.Server.Core, not in this transport library.
License and source
Licensed under AGPL-3.0-or-later. See the source repository and license.
For graceful application shutdown, StopAcceptingAsync() closes the listener and cancels unfinished stream preparation while established connections remain usable. IsRunning becomes false during this drain, while Endpoint retains a safe snapshot of the bound address and port. Drain application work, then call StopAsync() or DisposeAsync(). A new listener generation requires a complete stop before restart.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Serilog (>= 4.4.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Moongate.Network:
| Package | Downloads |
|---|---|
|
Moongate.Server.Core
Plugin-facing server contracts, events, registries, and dependency injection extensions for Moongate. |
|
|
Moongate.Api
Standalone typed MessagePack request/reply channels over mutually authenticated TLS with bounded execution and local peer authorization. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.19.0 | 74 | 10/16/2026 |
| 0.18.0 | 43 | 10/16/2026 |
| 0.17.0 | 106 | 10/14/2026 |
| 0.16.0 | 113 | 10/9/2026 |
| 0.15.0 | 99 | 10/7/2026 |
| 0.14.0 | 105 | 10/4/2026 |
| 0.13.0 | 108 | 10/3/2026 |
| 0.12.0 | 104 | 10/2/2026 |
| 0.11.0 | 114 | 9/30/2026 |
| 0.10.0 | 112 | 9/30/2026 |
| 0.9.0 | 120 | 9/27/2026 |
| 0.8.0 | 126 | 9/26/2026 |
| 0.7.0 | 107 | 9/24/2026 |
| 0.6.0 | 124 | 9/21/2026 |
| 0.5.0 | 122 | 9/20/2026 |
| 0.4.1 | 117 | 9/20/2026 |
| 0.4.0 | 123 | 9/19/2026 |
| 0.3.0 | 112 | 9/18/2026 |