Nalix.Hosting
14.4.0
dotnet add package Nalix.Hosting --version 14.4.0
NuGet\Install-Package Nalix.Hosting -Version 14.4.0
<PackageReference Include="Nalix.Hosting" Version="14.4.0" />
<PackageVersion Include="Nalix.Hosting" Version="14.4.0" />
<PackageReference Include="Nalix.Hosting" />
paket add Nalix.Hosting --version 14.4.0
#r "nuget: Nalix.Hosting, 14.4.0"
#:package Nalix.Hosting@14.4.0
#addin nuget:?package=Nalix.Hosting&version=14.4.0
#tool nuget:?package=Nalix.Hosting&version=14.4.0
Nalix.Hosting
Builder-style hosting API for Nalix network servers.
Nalix.Hosting provides the top-level application bootstrap layer. It wires protocols, listeners, packet handlers, options, logging integration, diagnostics, and lifecycle management behind a compact builder API.
Install
dotnet add package Nalix.Hosting
What It Provides
| Area | Purpose | Main types |
|---|---|---|
| Application host | Start, stop, run, and dispose a Nalix server | NetworkApplication |
| Builder API | Configure listeners, handlers, options, and services | NetworkApplicationBuilder, INetworkApplicationBuilder |
| Protocol binding | Bind TCP, datagram (NDP over UDP), and WebSocket protocols | MapTcp<TProtocol>(), MapDatagram<TProtocol>(), MapWebSocket<TProtocol>() |
| Handler registration | Register generated packet handlers explicitly | MapHandlers<T>(), MapHandlers(Type) |
| Default protocol | Forward packets into the dispatch pipeline with minimal setup | DefaultProtocol |
| Options | Host bootstrap and runtime settings | HostingOptions |
Minimal Server
using Nalix.Hosting;
await using NetworkApplication app = NetworkApplication.CreateBuilder()
.MapTcp<DefaultProtocol>()
.OnPort(8080)
.Bind()
.MapHandlers<MyPacketHandler>()
.Build();
await app.RunAsync();
Multiple Transports
using Nalix.Hosting;
using Nalix.Network.Options;
NetworkApplicationBuilder builder = NetworkApplication.CreateBuilder();
builder.MapTcp<DefaultProtocol>()
.OnPort(57200)
.Bind();
// Datagram sessions: clients get a ticket over TCP/WebSocket, then use UDP alone.
builder.MapDatagram<DefaultProtocol>()
.OnPort(57201)
.Bind();
builder.MapWebSocket<DefaultProtocol>()
.OnPort(57207)
.WithPath("/ws/")
.Bind();
builder.Configure<NetworkSocketOptions>(options =>
{
options.NoDelay = true;
options.BufferSize = 65536;
});
builder.MapHandlers<MyPacketHandler>();
await using NetworkApplication app = builder.Build();
await app.RunAsync();
One Host Per Process
A process runs one NetworkApplication at a time. A host is a façade over process-wide state, so a second
host in the same process does not get its own copy of that state. It replaces the first host's state:
| State | Where it lives | What a second host does to the first |
|---|---|---|
Service registry (IConnectionHub, IConnectionGuard, IPacketDispatch, IBufferPoolManager, IObjectPoolManager, ILogger, session services) |
InstanceManager.Instance, one per process. Registration is by type and the last one wins. |
Code that resolves a service through the registry, such as handlers, middleware and connections, gets the second host's instance. |
| Server identity for the X25519 handshake | Static fields of HandshakeHandlers, also exposed as HandshakeHandlers.ServerPublicKey |
Both hosts answer handshakes with one identity, so a client that pinned the first host's key fails the handshake. |
| Buffer and object pools | BufferPoolManager / ObjectPoolManager.Shared, one per process |
Pool sizing and reports cover both hosts. |
| Background workers | TaskManager from the registry. DeactivateAsync waits on the process-wide net/* and time/* groups. |
Stopping one host also waits on the other host's workers, so its shutdown stalls until the other host stops. |
| Options | ConfigurationManager.Instance, one per process |
Both hosts read the same option instances. |
This is by design. Hot-path code resolves these services from static or process-wide holders, so no per-host
lookup sits on the receive and dispatch paths. The handshake identity is part of the public API as a static
member (HandshakeHandlers.ServerPublicKey). Giving each host its own copy would change the public API of
several packages, not just Hosting.
What to do instead:
- Several ports or transports: use one host and call
MapTcp<T>(),MapUdp<T>()andMapWebSocket<T>()as many times as needed. All bindings share one dispatch pipeline, one identity and one set of pools. - Isolated servers (different identities, handlers or limits): run each one in its own process.
- Tests: dispose a host (
await app.DisposeAsync()) before you build the next one. Do not run tests that build hosts in parallel.
Migration Note
ListenTcp<TProtocol>() and ListenWebSocket<TProtocol>() are obsolete. Use MapTcp<TProtocol>() and
MapWebSocket<TProtocol>() for new code.
The UDP companion transport (MapUdp, ListenUdp, WithMode, WithAuthentication, IConnection.UDP) is removed.
Use MapDatagram<TProtocol>() on the server and DatagramSession in the SDK instead; handlers pick a delivery
method with [PacketDelivery(...)].
Documentation
- Package guide: https://ppn.io.vn/packages/nalix-hosting/
- API reference: https://ppn.io.vn/api/hosting/network-application/
| 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. net11.0 is compatible. |
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.8)
- Nalix.Abstractions (>= 14.4.0)
- Nalix.Codec (>= 14.4.0)
- Nalix.Framework (>= 14.4.0)
- Nalix.Network (>= 14.4.0)
- Nalix.Runtime (>= 14.4.0)
-
net11.0
- Nalix.Abstractions (>= 14.4.0)
- Nalix.Codec (>= 14.4.0)
- Nalix.Framework (>= 14.4.0)
- Nalix.Network (>= 14.4.0)
- Nalix.Runtime (>= 14.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 14.4.0 | 880 | 11/22/2026 |
| 14.3.10 | 108 | 11/19/2026 |
| 14.3.9 | 10,185 | 10/27/2026 |
| 14.3.8 | 621 | 10/26/2026 |
| 14.3.7 | 3,800 | 10/24/2026 |
| 14.3.6 | 107 | 10/24/2026 |
| 14.3.5 | 203 | 10/6/2026 |
| 14.3.4 | 107 | 10/6/2026 |
| 14.3.3 | 147 | 9/26/2026 |
| 14.3.2 | 122 | 9/26/2026 |
| 14.3.1 | 3,342 | 8/29/2026 |
| 14.3.0 | 669 | 8/27/2026 |
| 14.2.18 | 802 | 8/13/2026 |
| 14.2.17 | 656 | 8/11/2026 |
| 14.2.16 | 420 | 8/1/2026 |
| 14.2.15 | 141 | 7/31/2026 |
| 14.2.14 | 139 | 7/31/2026 |
| 14.2.13 | 157 | 7/31/2026 |
| 14.2.12 | 166 | 7/29/2026 |
| 14.2.11 | 148 | 7/28/2026 |
- Unified Server Bootstrapping: Simplified Microsoft-style host builder APIs for seamless TCP and UDP transport orchestration.
- Diagnostic Event Bridge: Automatic bridging of DiagnosticListener events from Nalix.Environment and Nalix.Framework into ILogger with configurable minimum log level.
- Pluggable Security Hooks: Added support for custom UDP authentication predicates and security filtering directly during the build phase.
- Coordinated Lifecycle: Advanced management of configuration reloads, dispatch activation, and listener startup for robust service availability.
- Dependency-Injection Integration: Streamlined registration of core network services into the standard Nalix InstanceManager.