Skip to content

Lightweight library for method calls over named pipes for IPC in .NET Core. Supports two-way communication with callbacks.

License

Notifications You must be signed in to change notification settings

manofstick/PipeMethodCalls

 
 

Repository files navigation

PipeMethodCalls

Lightweight library for method calls over named and anonymous pipes for IPC in .NET Core. Supports two-way communication with callbacks.

Calls from client to server

var pipeServer = new PipeServer<IAdder>("mypipe", () => new Adder());
await pipeServer.WaitForConnectionAsync();
var pipeClient = new PipeClient<IAdder>("mypipe");
await pipeClient.ConnectAsync();
int result = await pipeClient.InvokeAsync(a => a.AddNumbers(1, 3));

Calls both way

var pipeServer = new PipeServerWithCallback<IConcatenator, IAdder>("mypipe", () => new Adder());
await pipeServer.WaitForConnectionAsync();
string concatResult = await pipeServer.InvokeAsync(c => c.Concatenate("a", "b"));
var pipeClient = new PipeClientWithCallback<IAdder, IConcatenator>("mypipe", () => new Concatenator());
await pipeClient.ConnectAsync();
int result = await pipeClient.InvokeAsync(a => a.AddNumbers(4, 7));

About the library

This library uses named pipes to invoke method calls on a remote endpoint. The method arguments are packaged up in JSON, encoded and sent over the pipe.

Features

  • 100% asynchronous communication with .ConfigureAwait(false) to minimize context switches and reduce thread use
  • 39KB with Newtonsoft JSON as only dependency
  • Invoking async methods
  • Passing and returning complex types via JSON serialization
  • Interleaved or multiple simultaneous calls
  • Throwing exceptions
  • CancellationToken support
  • Works on Windows, Linux and MacOS

Not supported

  • Methods with out and ref parameters
  • Properties
  • Method overloads

Improvements

Let me know if you have any interest in supporting alternate serializers like System.Text.Json, Utf8Json or MessagePack.

About

Lightweight library for method calls over named pipes for IPC in .NET Core. Supports two-way communication with callbacks.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%