Skip to content

Repository files navigation

CI buildStable build
Build StatusBuild Status

IpcServiceFramework

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.

NuGet packages

NamePurposeStatus
JKang.IpcServiceFramework.Client.NamedPipeClient SDK to consume IPC service over Named pipeNuGet version
JKang.IpcServiceFramework.Client.TcpClient SDK to consume IPC service over TCPNuGet version
JKang.IpcServiceFramework.Hosting.NamedPipeServer SDK to run Named pipe IPC service endpointNuGet version
JKang.IpcServiceFramework.Hosting.TcpServer SDK to run TCP IPC service endpointNuGet version

Usage

  1. 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);}
  2. Implement the service in server application, for example:

    classInterProcessService:IInterProcessService{publicstringReverseString(stringinput){char[]charArray=input.ToCharArray();Array.Reverse(charArray);returnnewstring(charArray);}}
  3. Install the following NuGet packages in server application:

    >Install-Package Microsoft.Extensions.Hosting
    >Install-Package JKang.IpcServiceFramework.Hosting.NamedPipe
  4. 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);});}
  5. Install the following NuGet package in client application:

    >Install-Package JKang.IpcServiceFramework.Client.NamedPipe
  6. 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));

FAQs

About

.NET Core Inter-process communication framework

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages