| CI build | Stable build |
|---|---|
A .NET Core 3.1 based lightweight framework for efficient inter-process communication. Named pipeline and TCP support out-of-the-box, extensible with other protocols.
Create an interface as service contract and package it in an assembly to be referenced by server and client applications, for example:
publicinterfaceIInterProcessService{stringReverseString(stringinput);}
Implement the service in server application, for example:
classInterProcessService:IInterProcessService{publicstringReverseString(stringinput){char[]charArray=input.ToCharArray();Array.Reverse(charArray);returnnewstring(charArray);}}
Install the following NuGet packages in server application:
>Install-Package Microsoft.Extensions.Hosting >Install-Package JKang.IpcServiceFramework.Hosting.NamedPipe
Register the service implementation and configure IPC endpoint(s):
classProgram{publicstaticvoidMain(string[]args){CreateHostBuilder(args).Build().Run();}publicstaticIHostBuilderCreateHostBuilder(string[]args)=>Host.CreateDefaultBuilder(args).ConfigureServices(services =>{services.AddScoped<IInterProcessService,InterProcessService>();}).ConfigureIpcHost(builder =>{// configure IPC endpointsbuilder.AddNamedPipeEndpoint<IInterProcessService>(pipeName:"pipeinternal");}).ConfigureLogging(builder =>{// optionally configure loggingbuilder.SetMinimumLevel(LogLevel.Information);});}
Install the following NuGet package in client application:
>Install-Package JKang.IpcServiceFramework.Client.NamedPipe
Invoke the server
// register IPC clientsServiceProviderserviceProvider=newServiceCollection().AddNamedPipeIpcClient<IInterProcessService>("client1",pipeName:"pipeinternal").BuildServiceProvider();// resolve IPC client factoryIIpcClientFactory<IInterProcessService>clientFactory=serviceProvider.GetRequiredService<IIpcClientFactory<IInterProcessService>>();// create clientIIpcClient<IInterProcessService>client=clientFactory.CreateClient("client1");stringoutput=awaitclient.InvokeAsync(x =>x.ReverseString(input));