赞
踩
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);
- std::cout << "call foo result: " << a << std::endl;
- system("pause");
- return 0;
- }
-
- // output: call foo result: 5
具体实现: https://github.com/button-chen/buttonrpc_cpp14
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。