Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

rpclib is a modern C++ msgpack-RPC server and client library

License

NotificationsYou must be signed in to change notification settings

rpclib/rpclib

Repository files navigation

Status

rpclib is looking for maintainers

If you're looking for a similar library with support for JSON-RPC and async operations, check outpackio.

Overview

rpclib is a RPC library for C++, providing both a client and server implementation. It is built using modern C++14, and as such, requires a recent compiler. Main highlights:

  • Expose functions of your program to be called via RPC (from any languageimplementing msgpack-rpc)
  • Call functions through RPC (of programs written in any language)
  • No IDL to learn
  • No code generation step to integrate in your build, just C++

Look&feel

Server

#include<iostream>#include"rpc/server.h"voidfoo() {    std::cout <<"foo was called!" << std::endl;}intmain(int argc,char *argv[]) {// Creating a server that listens on port 8080    rpc::serversrv(8080);// Binding the name "foo" to free function foo.// note: the signature is automatically captured    srv.bind("foo", &foo);// Binding a lambda function to the name "add".    srv.bind("add", [](int a,int b) {return a + b;    });// Run the server loop.    srv.run();return0;}

Whensrv.run() is called,rpclib starts the server loop which listens to incoming connectionsand tries to dispatch calls to the bound functions. The functions are called from the thread whererun was called from. There is alsoasync_run that spawns worker threads and returnsimmediately.

Client

#include<iostream>#include"rpc/client.h"intmain() {// Creating a client that connects to the localhost on port 8080    rpc::clientclient("127.0.0.1",8080);// Calling a function with paramters and converting the result to intauto result = client.call("add",2,3).as<int>();    std::cout <<"The result is:" << result << std::endl;return0;}

Status

All planned 1.0.0 features are done and tested; the current state is production-ready.

Who uses rpclib?

This list is updated as I learn about more people using the library; let meknow if you don't want your project listed here.

Thanks

rpclib builds on the efforts of fantastic C++ projects. In no particular order:

Shoutouts to

About

rpclib is a modern C++ msgpack-RPC server and client library

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp