ZetaIpc 1.0.3.12

There is a newer version of this package available.
See the version list below for details.
dotnet add package ZetaIpc --version 1.0.3.12
NuGet\Install-Package ZetaIpc -Version 1.0.3.12
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="ZetaIpc" Version="1.0.3.12" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ZetaIpc --version 1.0.3.12
#r "nuget: ZetaIpc, 1.0.3.12"
#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.
// Install ZetaIpc as a Cake Addin
#addin nuget:?package=ZetaIpc&version=1.0.3.12

// Install ZetaIpc as a Cake Tool
#tool nuget:?package=ZetaIpc&version=1.0.3.12

Zeta IPC

A tiny .NET library to do inter-process communication (IPC) between different processes on the same machine.

NuGet

Get the ZetaIpc NuGet package.

Background

First trying ZeroMQ to do some very small IPC between two WinForms processes on the same machine, I failed and didn't bother to dig deeper. Instead I used the phantastic C# WebServer project and quickly assembled some small wrapper.

I intentionally implemented only simple string send and receive methods, everything else is out of scope of the library. E.g. you could use Json.NET to transfer JSON within the strings between the client and the server.

Using the server

To use the server (i.e. the "thing" that listens for incoming request and answers them), do something like:

var s = new IpcServer();
s.Start(12345); // Passing no port selects a free port automatically.

Console.WriteLine("Started server on port {0}.", s.Port);

s.ReceivedRequest += (sender, args) =>
{
    args.Response = "I've got: " + args.Request;
    args.Handled = true;
};

This starts a new background thread and continues execution.

Later, simply call

s.Stop();

to stop the server again.

Using the client

To use the client (i.e. the "thing" that can send texts to the server), do something like:

var c = new IpcClient();
c.Initialize(12345);

Console.WriteLine("Started client.");

var rep = c.Send("Hello");
Console.WriteLine("Received: " + rep);

Bi-directional usage

If you want a bi-directional communication between the server and client that can be started by both the client and the server, simply use the above code of the server on the client and the code of the client on the server (use different ports, of course).

This gives you two applications, each of them being server and client at the same time.

How to tell the port from the client to the server?

I've developed the library to start an external application from my main application. My main application acts as the client and my external application as the server.

The whole process of starting and communicating with the external application roughly follows these steps:

  1. Main application is running.
  2. User clicks a menu item, which requires to launch the external application.
  3. By calling the FreePortHelper.GetFreePort() method on the main application, a free port number is being gathered.
  4. The main application calls the external application (through a relative file path) and passes the free port number as a command line parameter to the external application.
  5. The external application reads the so passed port number from the command line and starts an instance of IpcServer on this given port.
  6. The main application waits for a few seconds and then uses an instance of IpcClient to send messages to the external application and receives messages back. If you want to wait until the server has really started and is ready, you can use an event wait handle.

Notes

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on ZetaIpc:

Repository Stars
Quaver/Quaver
The ultimate community-driven, and open-source competitive rhythm game available on Steam.
boonkerz/teamscreen
It should be an Teamviewer/Vnc/Something replacement
Version Downloads Last updated
1.0.4.12 6,240 1/14/2022
1.0.3.12 313 1/14/2022
1.0.2.12 274 1/14/2022
1.0.0.11 2,681 12/23/2020
1.0.0.9 8,201 5/19/2019
1.0.0.8 1,326 1/3/2019
1.0.0.7 709 1/3/2019
1.0.0.6 8,036 2/10/2018
1.0.0.5 1,794 3/7/2015