SharmIPC 1.20.0
dotnet add package SharmIPC --version 1.20.0
NuGet\Install-Package SharmIPC -Version 1.20.0
<PackageReference Include="SharmIPC" Version="1.20.0" />
<PackageVersion Include="SharmIPC" Version="1.20.0" />
<PackageReference Include="SharmIPC" />
paket add SharmIPC --version 1.20.0
#r "nuget: SharmIPC, 1.20.0"
#addin nuget:?package=SharmIPC&version=1.20.0
#tool nuget:?package=SharmIPC&version=1.20.0
SharmIPC .NET
Inter-process communication (IPC engine) between 2 partner processes of one OS: <br>- .NET Framework 4.5 > /.NETCore 2.0 / .NETStandard 2.0 / .NET 6> . Based on memory-mapped files and on NamedPipes <br>- Written on C# <br>- Fast and lightweight <br>- Sync and Async calls with timeouts <br>- a la RPC <br>- a la send and forget
- <a href = 'https://www.nuget.org/packages/SharmIPC/' target='_blank'>Grab it from NuGet</a>
- <a href = 'https://github.com/hhblaze/SharmIPC/tree/master/Process1/SharmIpc/bin/Release/' target='_blank'>Assemblies</a>
===================== Usage example:
//Added SharmNPC that works under .NET6> on Linux (named MemoryMappedFiles are not supported there).
//Both versions are included and usable. SharmNPC is based on Named Pipes and represents a complete drop-in replacement.
//In SharmNPC case one process becomes server and another client.
//Before we made
tiesky.com.SharmIpc sm = null;
//Now we can change
tiesky.com.ISharm sm = null;
//and use any of it SharmIpc (Win) or SharmNPC (Win, Linux).
//server listener
sm = new tiesky.com.SharmNpc("MNPC", tiesky.com.SharmNpcInternals.PipeRole.Server, this.RemoteCall);
//or
//client listener
sm = new tiesky.com.SharmNpc("MNPC", tiesky.com.SharmNpcInternals.PipeRole.Client, this.AsyncRemoteCallHandler);
//the rest is the same - drop-in.
//Note, currently there is a connection timeout (when server or client waits longer than 30 seconds of the connection, it stops).
//Also after established communication, when one of peers Disconnects - the other doesn't restore listening/connecting behaviour.
//All that is possible, but these are just different behavior strategies.
//In this first version of SharmNpc we don't give much flexibility for that setup - later or by request.
//Process 1 and Process2
tiesky.com.SharmIpc sm = null;
void Init()
{
if(sm == null)
sm = new tiesky.com.SharmIpc(
"My unique name for interpocess com in the OS scope, must be the same for both processes"
, this.RemoteCall
//unique name must start from the prefix "Global/" to make communication available
// for processes executed by different OS users
//there are also extra parameters in constructor with description:
//optional send buffer capacity, must be the same for both partners
//optional total not send messages buffer capacity
);
}
void Dispose()
{
//!!!For the graceful termination, in the end of your program,
//SharmIpc instance must be disposed
if(sm != null){
sm.Dispose();
sm=null;
}
}
Tuple<bool,byte[]> RemoteCall(byte[] data)
{
//This will be called async when remote partner makes any request
//This is a response to remote partner
return new Tuple<bool,byte[]>(true,new byte[] {1,2,3,4});
}
void MakeRemoteRequestWithResponse()
{
//Making remote request (a la RPC). SYNC
Tuple<bool,byte[]> res = sm.RemoteRequest(new byte[512]);
//or with callback
//var res = sm.RemoteRequest(data, (par) => { },30000);
//if !res.Item1 then our call was not put to the sending buffer,
//due to its threshold limitation
//or remote partner answered with technical mistake
//or timeout encountered
if(res.Item1)
{
//Analyzing response res.Item2
}
}
// async/await pattern
async void MakeRemoteRequestWithResponse()
{
//Making remote request (a la RPC). SYNC
//Non-blocking current thread construction!
Tuple<bool,byte[]> res = await sm.RemoteRequestAsync(new byte[512]);
//or with callback way
//var res = await sm.RemoteRequestAsync(data, (par) => { },30000);
//if !res.Item1 then our call was not put to the sending buffer,
//due to its threshold limitation
//or remote partner answered with technical mistake
//or timeout encountered
if(res.Item1)
{
//Analyzing response res.Item2
}
}
void MakeRemoteRequestWithoutResponse()
{
//Making remote request (a la send and forget)
Tuple<bool,byte[]> res = sm.RemoteRequestWithoutResponse(new byte[512]);
if(!res.Item1)
{
//Our request was not cached for sending, we can do something
}
}
//----starting from v1.04 it's possible to answer on remote call in async way:
//New way of instantiation of SharmIPC
//sm = new tiesky.com.SharmIpc("MyUniqueNameForBothProcesses",this.AsyncRemoteCallHandler);
//where AsyncRemoteCallHandler will be used instead of RemoteCall and gives an ability to answer to
//the remote partner's request in async way
void AsyncRemoteCallHandler(ulong msgId, byte[] data)
{
//msgId must be returned back
//data is received from remote partner
//answer to remote partner:
sm.AsyncAnswerOnRemoteCall(msgId, new Tuple<bool, byte[]>(true, new byte[] { 5 }));
}
===================== Benchmarks:
[DLL size is 15 KB]
[512 bytes package in both directions]
Remote async and sync calls with response (a la RPC), full-duplex, with the speed of 20 MB/s.
Remote async calls without response (a la send and forget), full-duplex, with the speed of 80 MB/s.
[10000 bytes package in both directions]
Remote async and sync calls with response (a la RPC), full-duplex, with the speed of 320 MB/s.
Remote async calls without response (a la send and forget), full-duplex, with the speed of 700 MB/s.
[1 byte package in both directions]
Remote async and sync calls with response (a la RPC), full-duplex, with the speed of 40000 call/s.
Remote async calls without response (a la send and forget), full-duplex, with the speed of 120000 calls/s.
and if you need more speed, just add in both processes more SharmIPC instances
<a href = 'https://github.com/hhblaze/DBreeze' target='_blank'>---- Check also our DBreeze database for .NET ----</a>
hhblaze@gmail.com
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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. net9.0 was computed. 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. |
.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 is compatible. 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. |
This package has no dependencies.
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.20.0 | 74 | 4 days ago |
1.18.0 | 6,723 | 11/26/2019 |
1.17.1 | 589 | 11/18/2019 |
1.17.0 | 545 | 11/18/2019 |
1.16.0 | 2,210 | 9/30/2017 |
1.15.0 | 1,392 | 9/26/2017 |
1.14.0 | 1,422 | 9/11/2017 |
1.12.0 | 1,438 | 9/7/2017 |
1.11.0 | 1,371 | 9/4/2017 |
1.10.1 | 1,245 | 5/30/2017 |
1.10.0 | 1,065 | 4/24/2017 |
1.9.2 | 1,321 | 9/25/2016 |
1.9.1 | 1,056 | 9/25/2016 |
1.9.0 | 1,338 | 6/15/2016 |
1.8.0 | 1,062 | 6/9/2016 |
1.7.0 | 1,296 | 8/27/2015 |
1.6.0 | 1,329 | 7/15/2015 |
1.5.0 | 1,142 | 7/10/2015 |
1.4.0 | 1,132 | 7/8/2015 |
1.3.0 | 1,185 | 7/7/2015 |
1.2.0 | 1,136 | 6/24/2015 |
1.1.0 | 1,147 | 6/24/2015 |
More controls over messages as described in https://github.com/hhblaze/SharmIPC/issues/6