• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

button-chen/buttonrpc_cpp14: 几百行代码实现的modern c++ rpc library

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

button-chen/buttonrpc_cpp14

开源软件地址:

https://github.com/button-chen/buttonrpc_cpp14

开源编程语言:

C++ 77.0%

开源软件介绍:

buttonrpc - modern rpc framework for C++

  • ZeroMQ 作为网络层
  • 使用c++14开发

Features

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

Example

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

Dependences

Building

  • windows vs2015 或者更高版本, linux 添加编译选项:-std=c++1z

Usage

  • 1: 更多例子在目录 example/ 下



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
apache/activemq-cpp: Apache ActiveMQ CPP发布时间:2022-04-20
下一篇:
mohammedabdulbari/CPP发布时间:2022-04-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap