{"id":20827216,"url":"https://github.com/uwekeim/zetaipc","last_synced_at":"2025-04-05T14:07:01.333Z","repository":{"id":19658461,"uuid":"22911438","full_name":"UweKeim/ZetaIpc","owner":"UweKeim","description":"A tiny .NET library to do inter-process communication (IPC) between different processes on the same machine.","archived":false,"fork":false,"pushed_at":"2022-01-14T10:30:19.000Z","size":35668,"stargazers_count":156,"open_issues_count":0,"forks_count":27,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-29T13:08:56.764Z","etag":null,"topics":["c-sharp","dotnet","http","http-server","inter-process-communication","ipc","json","machine"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/ZetaIpc","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/UweKeim.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}},"created_at":"2014-08-13T10:10:29.000Z","updated_at":"2025-03-13T17:05:48.000Z","dependencies_parsed_at":"2022-08-07T09:15:29.542Z","dependency_job_id":null,"html_url":"https://github.com/UweKeim/ZetaIpc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UweKeim%2FZetaIpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UweKeim%2FZetaIpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UweKeim%2FZetaIpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UweKeim%2FZetaIpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UweKeim","download_url":"https://codeload.github.com/UweKeim/ZetaIpc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345853,"owners_count":20924102,"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","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":["c-sharp","dotnet","http","http-server","inter-process-communication","ipc","json","machine"],"created_at":"2024-11-17T23:11:27.408Z","updated_at":"2025-04-05T14:07:01.304Z","avatar_url":"https://github.com/UweKeim.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Zeta IPC\n\nA tiny .NET library to do inter-process communication (IPC) between different processes on the same machine.\n\n## NuGet\n\nGet the [`ZetaIpc` NuGet package](https://www.nuget.org/packages/ZetaIpc).\n\n## Background\n\nFirst trying [ZeroMQ](https://github.com/zeromq/netmq) to do some very small IPC between two WinForms processes on the same machine, I failed and didn't \nbother to dig deeper. Instead I used the phantastic [C# WebServer project](https://webserver.codeplex.com/) and quickly\nassembled some small wrapper.\n\nI intentionally implemented only simple string send and receive methods, everything else is out of scope of\nthe library. E.g. you could use [Json.NET](http://james.newtonking.com/json) to transfer JSON within the strings between the client and the server.\n\n## Using the server\n\nTo use the server (i.e. the \"thing\" that listens for incoming request and answers them), do something like:\n\n```cs\nvar s = new IpcServer();\ns.Start(12345); // Passing no port selects a free port automatically.\n\nConsole.WriteLine(\"Started server on port {0}.\", s.Port);\n\ns.ReceivedRequest += (sender, args) =\u003e\n{\n    args.Response = \"I've got: \" + args.Request;\n    args.Handled = true;\n};\n```\n\nThis starts a new background thread and continues execution.\n\nLater, simply call\n\n```cs\ns.Stop();\n```\n\nto stop the server again.\n\n## Using the client\n\nTo use the client (i.e. the \"thing\" that can send texts to the server), do something like:\n\n```cs\nvar c = new IpcClient();\nc.Initialize(12345);\n\nConsole.WriteLine(\"Started client.\");\n\nvar rep = c.Send(\"Hello\");\nConsole.WriteLine(\"Received: \" + rep);\n```\n\n## Bi-directional usage\n\nIf you want a bi-directional communication between the server and client that can be started\nby both the client and the server, simply use the above code of the server on the client\nand the code of the client on the server (use different ports, of course).\n\nThis gives you two applications, each of them being server and client at the same time.\n\n## How to tell the port from the client to the server?\n\nI've developed the library to start an external application from my main application. My main application acts as \nthe client and my external application as the server. \n\nThe whole process of starting and communicating with the external application roughly follows these steps:\n\n1. Main application is running.\n1. User clicks a menu item, which requires to launch the external application.\n1. By calling the `FreePortHelper.GetFreePort()` method on the main application, a free port number is being gathered.\n1. 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.\n1. The external application reads the so passed port number from the command line and starts an instance of `IpcServer` on this given port.\n1. 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](http://stackoverflow.com/questions/2740038/).\n\n## Notes\n\n- The web server is included inside the ZetaIpc.dll, no need to ship additional DLLs.\n- Also available as a [NuGet package](https://www.nuget.org/packages/ZetaIpc).\n- I'm using this library in our [Test and Requirements Management application](http://www.zeta-test.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuwekeim%2Fzetaipc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuwekeim%2Fzetaipc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuwekeim%2Fzetaipc/lists"}