NexNet

NexNet

Real-time bidirectional networking for .NET. Source-generated hubs, multiple transports, zero reflection. AOT compatible.


Explore the Documentation

Getting Started

Install NexNet and build your first server-client hub in minutes.

Hub Invocations

Method patterns, return types, fire-and-forget, and broadcasting.

Sessions & Lifetimes

Hub lifecycle, session groups, ping, and automatic reconnection.

Synchronized Collections

Real-time INexusList with server-to-client, bidirectional, and relay modes.

Duplex Pipes

Stream raw bytes bidirectionally with built-in congestion control.

Channels

Type-safe streaming with INexusDuplexChannel<T> and IAsyncEnumerable.

Authentication

Token-based authentication with server-side validation.

Authorization

Declarative method and collection authorization with caching.

Versioning

Interface versioning with hash-lock validation and backward compatibility.

Transports

Six transport types: UDS, TCP, TLS, QUIC, WebSocket, and HttpSocket.

ASP.NET Integration

Middleware integration with DI, authentication, and reverse proxy support.

Rate Limiting

Connection rate limiting and DoS protection.


See It in Action

Define shared interfaces and let the source generator handle the rest:

public interface IClientNexus
{
    ValueTask<string> GetUserName();
}
public interface IServerNexus
{
    ValueTask<int> GetStatus(int userId);
}

[Nexus<IServerNexus, IClientNexus>(NexusType = NexusType.Server)]
partial class ServerNexus
{
    public ValueTask<int> GetStatus(int userId)
        => new(1);
}

// Connect and invoke
var server = ServerNexus.CreateServer(config, () => new ServerNexus());
await server.StartAsync();
await client.ConnectAsync();
var status = await client.Proxy.GetStatus(42);

The generator emits all hub and proxy classes at compile time — no reflection, no runtime code generation.


Quick Install

<PackageReference Include="NexNet" Version="*" />
<PackageReference Include="NexNet.Generator" Version="*-*">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

Why NexNet?

Source Generated

All hubs and proxies are emitted by a Roslyn source generator at compile time. No reflection, fully NativeAOT compatible.

Multiple Transports

Unix Domain Sockets, TCP, TLS, QUIC, WebSockets, and HttpSockets. Pick the right transport for each deployment.

Synchronized Collections

INexusList keeps data in sync across server and clients with server-to-client, bidirectional, and relay modes.

Duplex Streaming

Stream bytes via INexusDuplexPipe or typed data via INexusDuplexChannel<T> with built-in congestion control.

Auth & Authorization

Token-based authentication and declarative method-level authorization with [NexusAuthorize]. Caching included.

Auto Reconnection

Clients automatically reconnect on timeout or connection loss with no additional configuration required.