|
本帖最后由 802311chen 于 2018-8-14 07:07 编辑
1: 这个rpc的实现, 对于理解原理或者学习c++新标准非常有好处
github: https://github.com/button-chen/buttonrpc_cpp14
使用例子:
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 <iostream>
- #include "buttonrpc.hpp"
- int main()
- {
- buttonrpc client;
- client.as_client("127.0.0.1", 5555);
- int a = client.call<int>("foo", 2, 3).val();
- std::cout << "call foo result: " << a << std::endl;
- system("pause");
- return 0;
- }
- // output: call foo result: 5
复制代码
|
上一篇: Windows上使用CMake下一篇: [求助]无dll的远程线程注入导致被注入程序崩溃
|