当前位置:   article > 正文

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

buttonrpc github


server:

  1. #include "buttonrpc.hpp"
  2. int foo(int age, int mm){
  3. return age + mm;
  4. }
  5. int main()
  6. {
  7. buttonrpc server;
  8. server.as_server(5555);
  9. server.bind("foo", foo);
  10. server.run();
  11. return 0;
  12. }

client:

  1. #include <iostream>
  2. #include "buttonrpc.hpp"
  3. int main()
  4. {
  5. buttonrpc client;
  6. client.as_client("127.0.0.1", 5555);
  7. int a = client.call<int>("foo", 2, 3);
  8. std::cout << "call foo result: " << a << std::endl;
  9. system("pause");
  10. return 0;
  11. }
  12. // output: call foo result: 5


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



声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Li_阴宅/article/detail/807824
推荐阅读
相关标签
  

闽ICP备14008679号