项目作者: button-chen

项目描述 :
Tiny and simple c++ rpc library
高级语言: C++
项目地址: git://github.com/button-chen/buttonrpc.git
创建时间: 2018-04-28T15:49:00Z
项目社区:https://github.com/button-chen/buttonrpc

开源协议:

下载


buttonrpc - a simple rpc framework for C++

Features

  • 轻量级,跨平台,简单易用
  • 服务端可以绑定自由函数,类成员函数,std::function对象
  • 服务端可以绑定参数是任意自定义类型的函数
  • 客户端与服务端自动重连机制
  • 客户端调用超时选项

Example

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).val();
  8. std::cout << "call foo result: " << a << std::endl;
  9. system("pause");
  10. return 0;
  11. }
  12. // output: call foo result: 5

Dependences

Building

  • vs2010 或者更高版本 (为了兼容vs2010没有用到可变模板参数)
  • gcc/g++ 支持部分c++11特性即可

Usage