{"id":23454884,"url":"https://github.com/handyorg/handyipc","last_synced_at":"2026-03-15T07:02:56.243Z","repository":{"id":45912440,"uuid":"236776716","full_name":"HandyOrg/HandyIpc","owner":"HandyOrg","description":"An out-of-the-box inter-process communication (IPC) library, which can also be seen as a remote Ioc container.","archived":false,"fork":false,"pushed_at":"2023-08-27T14:30:16.000Z","size":341,"stargazers_count":32,"open_issues_count":6,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-08-27T13:09:48.629Z","etag":null,"topics":["csharp","dotnet","handy","ioc","ioc-container","ipc","msbuild","msbuild-task","remote-method-invocation","socket","source-generator"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HandyOrg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-01-28T16:06:29.000Z","updated_at":"2025-05-23T05:40:07.000Z","dependencies_parsed_at":"2024-01-29T10:19:13.878Z","dependency_job_id":null,"html_url":"https://github.com/HandyOrg/HandyIpc","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/HandyOrg/HandyIpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HandyOrg%2FHandyIpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HandyOrg%2FHandyIpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HandyOrg%2FHandyIpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HandyOrg%2FHandyIpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HandyOrg","download_url":"https://codeload.github.com/HandyOrg/HandyIpc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HandyOrg%2FHandyIpc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275779987,"owners_count":25527345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-18T02:00:09.552Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","dotnet","handy","ioc","ioc-container","ipc","msbuild","msbuild-task","remote-method-invocation","socket","source-generator"],"created_at":"2024-12-24T03:15:57.733Z","updated_at":"2025-09-18T13:54:07.047Z","avatar_url":"https://github.com/HandyOrg.png","language":"C#","readme":"# HandyIpc\n\nEnglish | [中文](./README.zh-CN.md)\n\nHandyIpc is an out-of-the-box inter-process communication (IPC) library, similar to WCF for remote method calls, but lighter in comparison, eliminating all the tedious configuration. You only need to read this README from the beginning to the master.\n\nThis library provides a high-level RMI (remote method invocation) API. Its underlying communication can be implemented by whatever you like, such as Named Pipe, MMF (memory mapping file) or Socket, and this framework does not care about the specific implementation.\n\n## NuGet\n\n| Package                    | Description                                                                        | NuGet                                                                                                                              |\n| -------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |\n| `HandyIpc`                 | The core library that provides the high-level APIs required for IPC communication. | [![version](https://img.shields.io/nuget/v/HandyIpc.svg)](https://www.nuget.org/packages/HandyIpc)                                 |\n| `HandyIpc.NamedPipe`       | Provides NamedPipe-based IPC.                                                      | [![version](https://img.shields.io/nuget/v/HandyIpc.NamedPipe.svg)](https://www.nuget.org/packages/HandyIpc.NamedPipe)             |\n| `HandyIpc.Socket`          | Provides Socket-based IPC, and only tcp protocol is currently supported.           | [![version](https://img.shields.io/nuget/v/HandyIpc.Socket.svg)](https://www.nuget.org/packages/HandyIpc.Socket)                   |\n| `HandyIpc.Serializer.Json` | Provides json serialization as the protocol for IPC.                               | [![version](https://img.shields.io/nuget/v/HandyIpc.Serializer.Json.svg)](https://www.nuget.org/packages/HandyIpc.Serializer.Json) |\n\n## Install Packages\n\nAdd the following 3 packages to your project.\n\nNote: `HandyIpc.NamedPipe` and `HandyIpc.Socket` only need to install one, it is recommended to choose `HandyIpc.NamedPipe`, it is faster than `HandyIpc.Socket`.\n\n```\n\u003cPackageReference Include=\"HandyIpc\" Version=\"0.5.2\" /\u003e\n\u003cPackageReference Include=\"HandyIpc.NamedPipe\" Version=\"0.5.0\" /\u003e\n\u003cPackageReference Include=\"HandyIpc.Serializer.Json\" Version=\"0.5.0\" /\u003e\n```\n\n## How to use\n\n#### 1. Define IPC contract\n\n```csharp\n// Declare an interface contains a set of methods that needs to be called remotely,\n// and mark it with IpcContractAttribute.\n[IpcContract]\n// Feature: Supports generic interfaces.\npublic interface IDemo\u003cT\u003e\n{\n    Task\u003cT\u003e GetDefaultAsync();\n    double Add(double x, double y);\n    // Feature: Supports Task/Task\u003cT\u003e async methods.\n    Task\u003cdouble\u003e AddAsync(double x, double y);\n    // Feature: Supports generic methdos.\n    string GetTypeName\u003cT\u003e();\n}\n```\n\n#### 2. Implement, register IPC contract in server side\n\n```csharp\n// Implement the IPC contract (interface).\npublic class Demo\u003cT\u003e : IDemo\u003cT\u003e\n{\n    public Task\u003cT\u003e GetDefaultAsync() =\u003e Task.FromResult\u003cT\u003e(default);\n    public double Add(double x, double y) =\u003e x + y;\n    public Task\u003cdouble\u003e AddAsync(double x, double y) =\u003e Task.FromResult(x + y);\n    public string GetTypeName\u003cT\u003e() =\u003e typeof(T).Name;\n}\n```\n\n```csharp\n// Create a ContainerServerBuilder instance to build the IContainerServer instance.\nContainerServerBuilder serverBuilder = new();\nserverBuilder\n    //.UseTcp(IPAddress.Loopback, 10086)\n    .UseNamedPipe(\"ec57043f-465c-4766-ae49-b9b1ee9ac571\")\n    .UseJsonSerializer();\n\nserverBuilder\n    // Generic interfaces that are not monomorphic need to be registered in this form.\n    .Register(typeof(IDemo\u003c\u003e), typeof(Demo\u003c\u003e))\n    // Non-generic interfaces or generic interfaces that are already monomorphic can use more elegant extension methods.\n    .Register\u003cIDemo\u003cstring\u003e, Demo\u003cstring\u003e\u003e()\n    .Register\u003cICalculator, Calculator\u003e();\n\nusing var server = serverBuilder.Build();\n// Don't forget to start the server.\nserver.Start();\n\n// server.Stop();\n```\n\n#### 3. Invoke remote methods in client side\n\n```csharp\n// Create a ContainerClientBuilder instance to build the IContainerClient instance.\nContainerClientBuilder clientBuilder = new();\nclientBuilder\n    //.UseTcp(IPAddress.Loopback, 10086)\n    .UseNamedPipe(\"ec57043f-465c-4766-ae49-b9b1ee9ac571\")\n    .UseJsonSerializer();\nusing var client = clientBuilder.Build();\n\n// Resolve contract instances from the client instance.\nvar demo1 = client.Resolve\u003cIDemo\u003cstring\u003e\u003e();\nvar demo2 = client.Resolve\u003cIDemo\u003cint\u003e\u003e();\n\n// Using contract instances, they will call an implementation from another process.\nvar result0 = demo1.Add(16, 26); // 42\nvar result1 = await demo1.AddAsync(40, 2); // 42\nvar result2 = demo1.GetTypeName\u003cstring\u003e(); // \"String\"\n\nvar result3 = await demo1.GetDefaultAsync(); // null\nvar result3 = await demo2.GetDefaultAsync(); // 0\n```\n\n## TODO List\n\n1. [x] Support for generic interface.\n2. [x] Support for `Task/Task\u003cT\u003e` return value in interface method.\n3. [x] Support for generic methods (parameter type allow contains nested generic types).\n4. [x] NOT support for interface inheritance.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhandyorg%2Fhandyipc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhandyorg%2Fhandyipc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhandyorg%2Fhandyipc/lists"}