Carubbi.Communication 2.1.0

dotnet add package Carubbi.Communication --version 2.1.0
                    
NuGet\Install-Package Carubbi.Communication -Version 2.1.0
                    
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="Carubbi.Communication" Version="2.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Carubbi.Communication" Version="2.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Carubbi.Communication" />
                    
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 Carubbi.Communication --version 2.1.0
                    
#r "nuget: Carubbi.Communication, 2.1.0"
                    
#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 Carubbi.Communication@2.1.0
                    
#: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=Carubbi.Communication&version=2.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Carubbi.Communication&version=2.1.0
                    
Install as a Cake Tool

Carubbi.Communication

NuGet NuGet Downloads

Implementation of named pipes stream to abstract the complexity. Allows you to use inter-process communication in a simple way.

Projects

Project Package
Carubbi.Communication Carubbi.Communication

Target framework: net10.0-windows (Windows only). Requires .NET 10 SDK.

Wire version compatibility: each library version uses its own wire protocol. Client and Server MUST run the same version (v2.1.0). Do not mix a v2.1.0 peer with a v2.0.0 peer — the transport and framing changed.

Usage

Server

Create a service class that inherits from Server<TRequestMessage, TResponseMessage> and implements ProcessRequest and BeforeStart:

using Carubbi.Communication.NamedPipe;

public class EchoService : Server<string, string>
{
    public EchoService() : base(nameof(EchoService))
    {
    }

    protected override string ProcessRequest(string requestMessage)
    {
        Console.WriteLine($"Message received: {requestMessage}");
        return $"Message sent: {requestMessage}";
    }

    protected override void BeforeStart()
    {
        Console.WriteLine("Server starting...");
    }
}

Start the service in your server app:

var service = new EchoService();
service.Start();

Client

Implement an IObserver<TResponseMessage> to receive the responses:

public class EchoServiceCallback : IObserver<string>
{
    public void OnNext(string value) => Console.WriteLine(value);
    public void OnError(Exception error) => Console.WriteLine(error.Message);
    public void OnCompleted() => Console.WriteLine("Request Completed");
}

Send requests from your client app:

using Carubbi.Communication.NamedPipe;

using (var client = new Client<string, string>("EchoService"))
{
    client.BeforeConnect += (sender, eventArgs) => Console.WriteLine("Connecting...");
    client.AfterEnd += (sender, eventArgs) => Console.WriteLine("Disconnected.");
    client.Subscribe(new EchoServiceCallback());
    client.Connect();

    Console.WriteLine("Type your message:");
    var message = Console.ReadLine();
    client.SendRequest(new List<string> { message });
}

The pipe names default to {processName}_SERVER_PIPE (client → server) and {processName}_CALLBACK_PIPE (server → client). Both the server and the client must use the same processName, or pass explicit serverPipeName/callbackPipeName values.

Serialization formats

Messages are serialized with a pluggable strategy. Choose it on both the server and the client constructors via the MessageFormat argument (default MessageFormat.Xml):

Format Notes
MessageFormat.Xml Default. Uses System.Xml.Serialization.XmlSerializer (BCL). Any public POCO.
MessageFormat.Json Uses System.Text.Json (BCL). Any public POCO.
MessageFormat.Binary Custom reflection-based encoder (BinaryWriter/BinaryReader) over public read/write properties. Supports primitives, string, char, DateTime, TimeSpan, Guid, decimal, enum, byte[], arrays and List<T>.
MessageFormat.Protobuf Uses protobuf-net. Message types must be annotated with [ProtoContract] / [ProtoMember].
// Both peers must use the same format.
var server = new EchoService(format: MessageFormat.Protobuf);
var client = new Client<string, string>("EchoService", format: MessageFormat.Protobuf);

For full control, pass your own serializers implementing IMessageSerializer<T>:

var client = new Client<string, string>(
    customRequestSerializer,   // IMessageSerializer<List<string>>
    customResponseSerializer); // IMessageSerializer<string>

Network / cross-machine (".")

By default both peers connect on the local machine ("."). To communicate across the network, pass the remote peer's host on both sides:

  • ClientserverPipePath = the machine hosting the Server.
  • ServercallbackClientPath = the machine hosting the Client.
var client = new Client<string, string>("EchoService", serverPipePath: "192.168.1.50");
var server = new EchoService(callbackClientPath: "192.168.1.60");

Hosted pipes default to AllowEveryone() (PipeSecurity granting the Everyone SID read/write), which is required for remote peers that run under a different account. Use NamedPipeSecurity.AllowEveryone() (default), NamedPipeSecurity.AllowCurrentUser(), or build a custom PipeSecurity and pass it as serverPipeSecurity / callbackPipeSecurity.

For security reasons .NET 10 removed the PipeSecurity overloads from the NamedPipeServerStream constructor; this library uses NamedPipeServerStreamAcl (part of the net10.0-windows framework, no extra package) to apply pipe security.

Samples

Run the server and the client samples to see a fully working round-trip:

dotnet run --project samples/Carubbi.Communications.ServerSample -c Release
dotnet run --project samples/Carubbi.Communication.ClientSample -c Release

Building and testing locally

Prerequisites: .NET SDK 10.

dotnet build Carubbi.Communication.slnx -c Release
dotnet run --project tests/Carubbi.Communication.Tests/Carubbi.Communication.Tests.csproj -c Release

Releasing

Pushing a tag v* (for example v2.0.0) triggers the publish workflow, which builds in Release mode, packs the library and publishes it to nuget.org using GitHub Actions trusted publishing.

Product Compatible and additional computed target framework versions.
.NET net10.0-windows7.0 is compatible. 
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
2.1.0 108 9/3/2026
2.0.0 96 9/3/2026
1.2.2 1,368 9/7/2018
1.2.1 1,078 9/5/2018
1.2.0 1,091 9/5/2018
1.1.4 1,096 9/5/2018
1.1.3 1,067 9/5/2018
1.1.2 1,080 9/5/2018
1.1.1 1,042 9/5/2018
1.1.0 1,075 9/4/2018
1.0.0 1,116 8/21/2018