{"id":16002832,"url":"https://github.com/soreing/rpc-service-cpp","last_synced_at":"2026-04-28T08:05:35.402Z","repository":{"id":110409818,"uuid":"394243090","full_name":"Soreing/rpc-service-cpp","owner":"Soreing","description":"Remote Procedure Call service library in C++","archived":false,"fork":false,"pushed_at":"2021-08-09T14:24:40.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T01:28:40.174Z","etag":null,"topics":["cpp","metaprogramming","remote-procedure-call","rpc","windows"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Soreing.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-09T10:13:35.000Z","updated_at":"2025-03-30T22:40:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"78062ddc-6c26-475f-ba58-c13f4bf4c1b0","html_url":"https://github.com/Soreing/rpc-service-cpp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Soreing/rpc-service-cpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Soreing%2Frpc-service-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Soreing%2Frpc-service-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Soreing%2Frpc-service-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Soreing%2Frpc-service-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Soreing","download_url":"https://codeload.github.com/Soreing/rpc-service-cpp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Soreing%2Frpc-service-cpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32371714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"online","status_checked_at":"2026-04-28T02:00:07.250Z","response_time":56,"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":["cpp","metaprogramming","remote-procedure-call","rpc","windows"],"created_at":"2024-10-08T10:04:25.455Z","updated_at":"2026-04-28T08:05:35.349Z","avatar_url":"https://github.com/Soreing.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rpc-service-cpp\n# Description\nrpc-service-cpp is a Remote Procedure Call library for C++. You can create a server that hosts functions with their implementation, and/or make a client that contacts the server to call a function and wait for a return value. Arguments for the functions get serialized to bytes and sent with the request.\n\n# Installation\nAdd the folder `rpc-service` from `/include` in your include path. If you want to compile the library from source, include `XSocket.cpp` and `RPCService.cpp` from the `/src` folder. Alternatively, you can compile the source code to a static library and include it that way.\n\n# Usage\nThe basic usage of the library is included in `DEMO_Server.cpp` to create an RPC Server and `DEMO_Client.cpp` to create a Client.\n\n## Creating a Server\nYou will need the following headers to create an RPC Server\n```c++\n#include \u003crpc-service/RPCService.h\u003e\n#include \u003crpc-service/RPCFunction.h\u003e\n```\n\nTo create a server that hosts specific functions, first you will need to create a list of functions with a list of parameters types using `MakeFunction()`.\n```c++\nauto RPCs = std::make_tuple(\n    MakeFunction(\"Function\", Type\u003cvoid\u003e(), NoFunction, std::tuple\u003c\u003e()),\n    MakeFunction(\"Divide\", Type\u003cfloat\u003e(), Divide, std::tuple\u003cType\u003cint\u003e, Type\u003cint\u003e \u003e()),\n    MakeFunction(\"TestFunction\", Type\u003cint\u003e(), TestFunction, std::tuple\u003cType\u003cint\u003e, Type\u003cint\u003e, Type\u003cADT\u003e \u003e())\n);\n``` \nThe `1st` parameter is the name ID of the function, the `2nd` parameter is the return type, `3rd` is the function pointer for the implementation, then the `4th` parameter is a tuple of types for parameters to the function call.  \n  \nAfter the list of functions is created, you need to create an interface to and RPC Service, then start hosting the service online on a port number.\n```c++\nauto service = MakeIRPCService(RPCs);\n\n// Service running on port 7971 for example\nif(service.Start(7971))\n{    while (true) {}\n}\n```\n\n## Creating a Client\nYou will need the following headers to create an RPC Client\n```c++\n#include \u003crpc-service/RPCService.h\u003e\n```\n\nTo create a client that contacts the RPC Server, you simply need to call a function with the correct parameters\n```c++\nfloat fresult;\nif(RPC(\"127.0.0.1\", 7971, fresult, \"Divide\", 3, 6))\n{    cout \u003c\u003c fresult;\n}\n```\nThe `RCP()` function returns `true` if the call was successful, `false` if it was not. Parameters are:\n\n1. IP address of the RPC Server\n2. Port number of the RPC Server\n3. Return value (Skip if the function has no return)\n4. Name ID of the requested function\n5. Any additional parameters will be converted to bytes and sent with the request as data for calling the function with.  \n  \nMore Examples:\n```c++\n// Function with no return value\nif(RPC(\"127.0.0.1\", 7971, \"Function\"))\n{    cout \u003c\u003c \"Call Succesful!\\n\\n\";\n}\n\n// Function with an abstract data type as a parameter\nint iresult;\nif (RPC(\"127.0.0.1\", 7971, iresult, \"TestFunction\", 1, 2, ADT(123, 456.789f)))\n{   cout \u003c\u003c iresult;\n}\n```\n\n## Working with Abstract Data Types\nYou can use classes and structures as arguemnts in the RPC calls only if both the server and the client defines them, and implement the required functions. Both functions have been defined for common C++ types.\n  \nThe `Marshall()` function converts the data type to an array of bytes as a string, while the `Unmarshall()` function converts a string of bytes to an object.\n\n```c++\nstr Marshall(ADT raw)\n{   return str((char*)\u0026raw, sizeof(raw));\n}\nADT Unmarshall(cstr data, int* size, Type\u003cADT\u003e)\n{    if (size != NULL) { *size = sizeof(ADT); } return *(ADT*)data;\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoreing%2Frpc-service-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoreing%2Frpc-service-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoreing%2Frpc-service-cpp/lists"}