Beskar.Networking.Transports.Tcp.Tests 1.1.1

dotnet add package Beskar.Networking.Transports.Tcp.Tests --version 1.1.1
                    
NuGet\Install-Package Beskar.Networking.Transports.Tcp.Tests -Version 1.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Beskar.Networking.Transports.Tcp.Tests" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Beskar.Networking.Transports.Tcp.Tests" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Beskar.Networking.Transports.Tcp.Tests" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Beskar.Networking.Transports.Tcp.Tests --version 1.1.1
                    
#r "nuget: Beskar.Networking.Transports.Tcp.Tests, 1.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Beskar.Networking.Transports.Tcp.Tests@1.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Beskar.Networking.Transports.Tcp.Tests&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Beskar.Networking.Transports.Tcp.Tests&version=1.1.1
                    
Install as a Cake Tool

<h1> <p align="center"> <img src="https://github.com/MarvinDrude/Beskar.Networking/blob/master/Resources/banner.png" alt="Logo" width="256" /> <br /> Beskar.Networking </p> </h1> <p align="center"> Fast, <code>.NET</code> native, high-performance, low-allocation networking library.<br/> Built for modern <code>.NET</code> using <code>C#</code> includes TCP, WebSockets, QUIC, and MQTT.<br/> No external runtime dependencies besides <b>Beskar</b>.<br/><br/> <a href="#about">About</a> · <a href="#examples">Examples</a> · <a href="#documenation">Documentation</a> · <a href="#performance-benchmarks">Performance</a> · <a href="#key-aspects">Key Aspects</a> </p> <br/>


<br/>

Code Poetry Issues Repo Size License: MIT

About

Main reasons for why you should consider using Beskar.Networking for your next Networking or MQTT use case:

  • Made with passion and love for the craft.
  • Built for modern .NET using C# and designed to be highly performant, low-allocation, and easy to use.
  • Purposefully designed to be lightweight and flexible.
  • Performance-first approach with 100,000 - 10,800,000 messages/packets per second. (Depending on various factors)
  • Many simple or more advanced example projects demonstrating how to use Beskar.Networking across various transports.
  • Various Unit Tests to verify functionality and performance.
  • Active development and steady progress towards a full feature set.
  • MQTT V3 and V5 support. (Server and Client) – Over any transport supported by Beskar.
  • No external runtime dependencies besides .NET and Beskar.

API Overview

Beskar.Networking offers different levels of abstraction depending on your application needs:

Low-Level Transports

The core library features protocol-agnostic, low-level interfaces:

  • INetworkListener - The Server listener that accepts incoming connections and manages sessions.
  • INetworkClient - The client that initiates connections and manages sessions.
  • INetworkSession - Represents a single connection between a client and server.
  • INetworkStream - Provides transport-agnostic handling (supporting TCP, WebSockets, or QUIC).

These interfaces provide transport-agnostic handling (supporting TCP, WebSockets, or QUIC). Because they are low-level, you are responsible for managing execution tasks yourself, such as starting your own accept loops, launching read/write tasks, and supervising session lifecycles.

Client Transport Optimization (Low-Level APIs) When instantiating TcpNetworkClient, WsNetworkClient, or QuicNetworkClient directly with custom options (TcpTransportOptions, WsTransportOptions, QuicTransportOptions), the default IoQueueCount is optimized for servers and defaults to Math.Min(Environment.ProcessorCount, 24).

For client-side applications, you should explicitly configure the option's IoQueueCount (e.g. options.StreamOptions.IoQueueCount = 1 and options.SocketOptions.IoQueueCount = 1) to 1. Since a client only manages a single connection, this prevents allocating unnecessary idle memory pools and thread queues, drastically reducing the unmanaged and pinned memory footprint.

For more details, see the Basics Documentation.

High-Level Managed APIs

For protocols like MQTT, Beskar.Networking provides fully managed implementations:

  • Fully Managed Broker & Client: Pre-built wrappers that manage the connection, session, and stream states automatically.
  • Event-Driven: Fully event-driven design with convenient events to react to incoming messages, client connections, and subscription actions, eliminating the need to write custom accept loops or pipeline plumbing.

In the future, additional managed APIs for other application protocols will be added here.


NuGet packages overview

Package / Project Description NuGet Link
Beskar.Mqtt.Server High-performance, low-allocation MQTT broker/server support for v3.1.1 and v5.0 over any transport. NuGet Version
Beskar.Mqtt.Client Lightweight and efficient MQTT client supporting v3.1.1 and v5.0 over any transport. NuGet Version
Beskar.Networking.Transports.Tcp High-performance, native TCP transport implementation supporting TLS. NuGet Version
Beskar.Networking.Transports.Ws WebSocket (WS/WSS) transport adapter wrapping custom framed duplex pipelines. NuGet Version
Beskar.Networking.Transports.Quic Multiplexed and secure QUIC transport implementation built on native .NET libraries. NuGet Version

Examples

We provide both basic and advanced example projects demonstrating how to use Beskar.Networking across various transports:

All examples: Root Folder

  • Simple Ping-Pong Message (Bare-metal): Demonstrates low-level server listener binding, client connection, and raw bidirectional message exchange using length-prefixed framing over System.IO.Pipelines using TCP.
  • Advanced Multi-Transport Chat Application: A complete chat application consisting of:
    • Common: Reusable packet serialization and custom packet framing utilities.
    • Server: Integrates a unified ChatServerBuilder to listen and accept chat sessions concurrently on TCP (9000), WebSockets (11000), and QUIC (12000).
    • Client: An interactive console application allowing users to connect via their choice of protocol (TCP/WS/QUIC), receive recent chat history, and chat in real-time under a random username.
  • MQTT Managed Examples: A set of projects demonstrating the high-level managed MQTT APIs:
    • Simple Publish-Subscribe: A complete pub-sub flow showing how to spin up an MQTT broker, connect a sensor client (publisher) and dashboard client (subscriber) over TCP using MQTT v5.0.
    • Generated Pub-Sub (Source Generator): Showcases how to use the high-performance MQTT Topic Source Generator to define compile-time validated topics and perform zero-allocation publishing using the generated byte[] format overloads.
    • Quality of Service (QoS) Levels: Demonstrates publishing and subscribing messages with different QoS levels (QoS 0: At Most Once, QoS 1: At Least Once, QoS 2: Exactly Once) using wildcard topic filters.
    • Authentication (v3 & v5 Challenges): Highlights both simple username/password validation for MQTT v3.1.1 and advanced challenge-response authentication for MQTT v5.0.
    • Client Reconnection & Event Handling: Shows how to register connection status events and implement custom auto-reconnection loops when connections are unexpectedly lost.

Documenation

You can find detailed documentation for Beskar.Networking here.

Or you can find examples directly here.

Performance Benchmarks

Engineered from the ground up for maximum throughput and minimum allocation overhead.

[!NOTE]
Computer Specs:<br/> CPU: AMD Ryzen 9 7950X3D, Memory: 64 GB DDR5

Method: Payload does not include protocol, Local Loopback Benchmark<br /> Note: Benchmarks are subject to change as the library evolves.

Transport / Protocol Clients Payload Size Throughput Bandwidth
TCP (No TLS) 20 128 bytes 10,805,651 packets/s 1,319.05 MB/s
TCP (No TLS) 20 512 bytes 7,355,303 packets/s 3,591.46 MB/s
WebSockets (WS) (No TLS) 20 128 bytes 10,784,817 packets/s 1,316.51 MB/s
WebSockets (WS) (No TLS) 20 512 bytes 6,968,596 packets/s 3,402.63 MB/s
QUIC 20 128 bytes 3,503,372 packets/s 427.66 MB/s
QUIC 20 512 bytes 954,711 packets/s 466.17 MB/s
MQTT (TCP - No TLS) 20 128 bytes 918,794.17 msg/s 112.16 MB/s
MQTT (TCP - No TLS) 20 512 bytes 674,086.45 msg/s 329.14 MB/s

Key Aspects

Beskar.Networking is a high-performance, low-allocation networking library built for modern .NET 10 using C#. It provides a unified, pipe-based interface abstraction (INetworkListener, INetworkClient, INetworkSession, INetworkStream) for building extremely fast network applications across multiple transport protocols.

  • Unified Abstractions: Write your network layer once and swap between TCP, WebSockets, or QUIC etc. dynamically.
  • Modern .NET 10 Stack: Heavily leverages System.IO.Pipelines (decoupling IO thread queues from application processing), Span<T>, ReadOnlySpan<T>, and direct memory pooling to achieve zero/near-zero allocations.
  • TLS/SSL Encryption: Full native SSL/TLS wrapping for TCP and WebSocket transports out of the box.
  • Non-blocking IO Queueing: Highly-optimized custom IO queues (like TcpIoQueueRegistry / TcpIoQueue) to handle asynchronous reading and writing concurrently.
  • Full MQTT:
  • Other Features: Additional features and capabilities that make this library unique and valuable.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.1.1 92 7/19/2026
1.1.0 93 7/19/2026
1.0.1 108 7/19/2026