世界上最好的c++ rpc实现基于c++14标准


server:

#include "buttonrpc.hpp"

int foo(int age, int mm){
	return age + mm;
}

int main()
{
	buttonrpc server;
	server.as_server(5555);

	server.bind("foo", foo);
	server.run();

	return 0;
}

client:

#include 
#include "buttonrpc.hpp"

int main()
{
	buttonrpc client;
	client.as_client("127.0.0.1", 5555);
	int a = client.call("foo", 2, 3);
	std::cout << "call foo result: " << a << std::endl;
	system("pause");
	return 0;
}

// output: call foo result: 5


具体实现: https://github.com/button-chen/buttonrpc_cpp14



你可能感兴趣的:(cpp)