Faster.Transport 0.0.9

There is a newer version of this package available.
See the version list below for details.
dotnet add package Faster.Transport --version 0.0.9
                    
NuGet\Install-Package Faster.Transport -Version 0.0.9
                    
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="Faster.Transport" Version="0.0.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Faster.Transport" Version="0.0.9" />
                    
Directory.Packages.props
<PackageReference Include="Faster.Transport" />
                    
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 Faster.Transport --version 0.0.9
                    
#r "nuget: Faster.Transport, 0.0.9"
                    
#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 Faster.Transport@0.0.9
                    
#: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=Faster.Transport&version=0.0.9
                    
Install as a Cake Addin
#tool nuget:?package=Faster.Transport&version=0.0.9
                    
Install as a Cake Tool

๐Ÿš€ Faster.Transport

Faster.Transport is a high-performance, unified transport layer for .NET that abstracts multiple communication backends โ€” including In-Process, Shared Memory (IPC), TCP, and UDP / Multicast โ€” under a single IParticle interface.

It is designed for ultra-low-latency, high-throughput messaging across local, inter-process, and network boundaries.


โœจ Features

Feature Description
๐Ÿง  Unified API All transports implement IParticle with Send, SendAsync, OnReceived, OnConnected, and OnDisconnected.
โšก Zero-Copy Messaging Uses ReadOnlyMemory<byte> and pooled buffers for minimal GC pressure.
๐Ÿงฉ Multiple Backends Supports Inproc, IPC, TCP, and UDP / Multicast.
๐Ÿ’ฌ Bi-Directional Communication Every IParticle is full-duplex: send and receive simultaneously.
๐Ÿงต Thread-Safe Built for high concurrency using lock-free queues.
๐Ÿ›ฐ๏ธ Multicast Support Native UDP multicast support with TTL, loopback control, and auto configuration.
๐Ÿงฐ Fluent Builder DSL Configure and build transports using a single fluent interface (ParticleBuilder).

๐Ÿงฑ Supported Transports

Transport Description Use Case
๐Ÿงฉ Inproc In-process memory channel, zero allocations Testing, simulations, multi-component apps
๐Ÿ’พ IPC Shared-memory transport via mapped files Cross-process, same machine
๐ŸŒ TCP Network transport, reliable streaming Client-server, LAN, remote
๐Ÿ“ก UDP Datagram transport, supports unicast & multicast Telemetry, broadcast, discovery

โš™๏ธ Benchmark Results

All benchmarks were run using BenchmarkDotNet on a .NET 9.0 build targeting x64 in Release mode.

๐Ÿงฉ Inproc Transport (Single Process)

Method Mean Error StdDev Median Allocated
๐Ÿ† SendAsync 10k messages 5.080 ms 7.134 ms 4.719 ms 2.260 ms 956.79 KB

Interpretation:
๐Ÿš€ The Inproc transport achieves ~2.2 ms median latency for 10,000 asynchronous message sends,
with under 1 MB total allocations, demonstrating near-zero overhead and outstanding local throughput.


๐Ÿ”ง Quick Start

1๏ธโƒฃ Create a TCP echo server and client

using Faster.Transport;
using System.Net;
using System.Text;

// ๐Ÿ–ฅ๏ธ Server
var server = new ParticleBuilder()
    .UseMode(TransportMode.Tcp)
    .BindTo(new IPEndPoint(IPAddress.Loopback, 5000))
    .OnReceived((p, msg) =>
    {
        Console.WriteLine($"Server received: {Encoding.UTF8.GetString(msg.Span)}");
        p.Send(msg.Span); // echo back
    })
    .Build();

// ๐Ÿ’ป Client
var client = new ParticleBuilder()
    .UseMode(TransportMode.Tcp)
    .ConnectTo(new IPEndPoint(IPAddress.Loopback, 5000))
    .OnReceived((_, msg) =>
        Console.WriteLine($"Client got echo: {Encoding.UTF8.GetString(msg.Span)}"))
    .Build();

await Task.Delay(200); // wait for connect
await client.SendAsync(Encoding.UTF8.GetBytes("Hello TCP!"));

2๏ธโƒฃ In-Process Messaging

var server = new ParticleBuilder()
    .UseMode(TransportMode.Inproc)
    .WithChannel("local-bus", isServer: true)
    .OnReceived((_, msg) =>
        Console.WriteLine($"Server received: {Encoding.UTF8.GetString(msg.Span)}"))
    .Build();

var client = new ParticleBuilder()
    .UseMode(TransportMode.Inproc)
    .WithChannel("local-bus")
    .Build();

await client.SendAsync(Encoding.UTF8.GetBytes("Ping Inproc!"));

3๏ธโƒฃ IPC (Shared Memory)

var server = new ParticleBuilder()
    .UseMode(TransportMode.Ipc)
    .WithChannel("shared-map", isServer: true)
    .OnReceived((_, msg) =>
        Console.WriteLine($"IPC Server: {Encoding.UTF8.GetString(msg.Span)}"))
    .Build();

var client = new ParticleBuilder()
    .UseMode(TransportMode.Ipc)
    .WithChannel("shared-map")
    .Build();

await client.SendAsync(Encoding.UTF8.GetBytes("Hello from IPC!"));

4๏ธโƒฃ UDP / Multicast Messaging

Now with auto-configuring multicast โ€” no need to manually bind or connect!

using Faster.Transport;
using System.Net;
using System.Text;

var group = IPAddress.Parse("239.10.10.10");
var port = 50000;

// ๐Ÿ›ฐ๏ธ Multicast Sender
var server = new ParticleBuilder()
    .EnableMulticast(group, port, disableLoopback: false)
    .Build();

// ๐Ÿ“ก Multicast Clients
var client1 = new ParticleBuilder()
    .EnableMulticast(group, port)
    .OnReceived((_, msg) =>
        Console.WriteLine($"Client 1 got: {Encoding.UTF8.GetString(msg.Span)}"))
    .Build();

var client2 = new ParticleBuilder()
    .EnableMulticast(group, port)
    .OnReceived((_, msg) =>
        Console.WriteLine($"Client 2 got: {Encoding.UTF8.GetString(msg.Span)}"))
    .Build();

Console.WriteLine("Press ENTER to send 3 multicast messages...");
Console.ReadLine();

for (int i = 0; i < 3; i++)
{
    var msg = Encoding.UTF8.GetBytes($"Broadcast #{i + 1}");
    await server.SendAsync(msg);
    Console.WriteLine($"[Server] Sent Broadcast #{i + 1}");
    await Task.Delay(300);
}

โœ… Output

[Server] Sent Broadcast #1
Client 1 got: Broadcast #1
Client 2 got: Broadcast #1
...

๐Ÿงฉ ParticleBuilder Overview

Method Description
.UseMode(TransportMode) Selects the backend (Tcp, Inproc, Ipc, or Udp).
.BindTo(IPEndPoint) Binds to a local endpoint (for servers or UDP listeners).
.ConnectTo(IPEndPoint) Connects to a remote endpoint (for clients).
.EnableMulticast(IPAddress, int, bool) Configures and auto-binds a UDP multicast socket.
.AllowBroadcast(bool) Enables UDP broadcast mode.
.WithChannel(string, bool) Used by Inproc and IPC transports.
.OnReceived(Action<IParticle, ReadOnlyMemory<byte>>) Handles incoming messages.
.OnConnected(Action<IParticle>) Triggered when connection is ready.
.OnDisconnected(Action<IParticle, Exception?>) Triggered when connection closes.
.WithBufferSize(int) Sets per-operation buffer size.
.WithRingCapacity(int) Sets internal shared memory size (IPC/Inproc).
.WithParallelism(int) Sets degree of parallelism.

๐Ÿงช Testing UDP Multicast Locally

If messages are not received:

  1. Ensure disableLoopback: false in .EnableMulticast() for local tests.
  2. Disable the firewall or open UDP port 50000.
  3. Verify via Wireshark: filter udp.port == 50000.
  4. Loopback works only if MulticastLoopback is enabled.

โš™๏ธ Requirements

Requirement Minimum
.NET .NET 9.0 or newer
OS Windows, Linux, macOS
Recommended .NET 8+ for maximum performance

๐Ÿง‘โ€๐Ÿ’ป Example Projects

Project Description
Faster.Transport.Demo Contains TCP, Inproc, IPC, and UDP demos
Faster.Transport.Tests Includes integration & multicast test suite
Faster.Transport.Primitives Zero-copy buffer and ring-based queue utilities

๐Ÿงฐ License

MIT License ยฉ 2025 โ€” Designed for speed, simplicity, and reliability.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Faster.Transport:

Package Downloads
Faster.Messagebus

A high-performance, low-allocation messaging bus for .NET, built on NetMQ for transport and MessagePack for efficient serialization. Designed for speed and ease of use in distributed systems.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.21 274 11/14/2025
0.0.20 170 11/8/2025
0.0.19 163 11/8/2025
0.0.18 344 11/4/2025
0.0.17 220 11/2/2025
0.0.16 212 11/2/2025
0.0.15 143 11/1/2025
0.0.14 209 10/29/2025
0.0.13 209 10/29/2025
0.0.12 205 10/29/2025
0.0.11 207 10/29/2025
0.0.10 158 10/26/2025
0.0.9 160 10/26/2025
0.0.8 149 10/24/2025
0.0.7 200 10/23/2025
0.0.6 199 10/23/2025
0.0.5 197 10/23/2025
0.0.4 186 10/23/2025
0.0.3 204 10/23/2025
0.0.2 202 10/23/2025
Loading failed