Json-RPC框架框架介绍与环境搭建Ubuntu-22.04

目录

【Json RPC框架】框架介绍与环境搭建(Ubuntu 22.04)

🎁个人主页:

🔍系列专栏:

🌷 追光的人,终会万丈光芒

🎉欢迎大家点赞👍评论📝收藏⭐文章

https://i-blog.csdnimg.cn/direct/704149dd1e2c4fbcaa3ab4f21dd339bf.gif

https://i-blog.csdnimg.cn/direct/5271d18c85414d2bb23d348c908c47aa.gif

| | |

JSon RPC框架系列文章

RPC是 远程过程调用。

通过网络,向服务器请求服务,调用服务器上的函数或者方法,不用关心 网络底层细节 ,就好像在本地调用一样简单和实用。从而实现分布式服务交互,可以使用的网络通信协议有HTTP,UDP,TCP。

侧重点,带给人的感受是像是在直接调用本地函数一样。

Json是一种数据格式,用于存储数据和表示数据。

Json在网络数据交互的时候承担着重要的作用,在网络通信的过程中要序列化和反序列化。

https://i-blog.csdnimg.cn/direct/f3cbde84c4a94f1c9442eacd3295550c.png

muduo库是C++中高性能的网络库,用于开发高并发的网络服务器。采用Reacter模式,和非阻塞IO,事件驱动的,最大程度的利用CPU。

muduo库的设计核心是一个线程一个事件循环,主线线程负责窃听新连接,然后分配给其他线程。

序列化协议,通信协议,连接复用,服务注册,服务发现,服务订阅和服务通知,负载均衡,同步调用,异步调用。

通过 实现远程调用接口,传入函数参数,进行远程调用RPC接口。通过Json设计好

参数和返回值协议 。直接采用Json进行序列化和反序列化。


Linux(Ubuntu22.04)
vscode/vim
g++
Makefile

https://i-blog.csdnimg.cn/direct/987314983b6948e9bc810a3304ef8672.png


sudo apt-get install wget

wget的功能是从服务器下载工具,如果没有这个,就不能下载其他的,所以一般是有这个这个工具的。

wget --version

https://i-blog.csdnimg.cn/direct/6816b59e9b094a098ece7733b3149d7f.png

wget版本1.21.2,建立在Linux-gnu之上。


更新国内的软件源,下载速度更快,下载东西就不要等很久了。而且国内的软件源更加的安全,稳定可靠,本地支持性也更好。

下载工具的时候,就直接去这个服务器上找,下载速度更快。

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
#添加清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

注意格式,deb开头为一行,其他的如果中间换行可能就会出错。

错误示范:

一行写成了这样: multiverse不能写到第二行,不然不能解析。

**deb-src focal main restricted universe

multiverse**

正确写法:应该都是deb开头,一行写完,中间不能换行。

deb-src focal main restricted universe multiverse

https://i-blog.csdnimg.cn/direct/65b34a2172874d4db41faf4e5ed181b4.png

第3行格式错误,不能读取源文件列表。

sudo apt-get update

sudo apt-get install lrzsz

rz服务器接收文件到服务器。

sz从服务器发送文件到客户端(本地)。

https://i-blog.csdnimg.cn/direct/19a3132e18ed4e3dacb898f44dbdd7b6.png


sudo apt-get install gcc g++

https://i-blog.csdnimg.cn/direct/67271420fe534d8b81f4f4543b3ad9a0.png


sudo apt-get install make

sudo apt-get install gdb

sudo apt-get install git

sudo apt-get install cmake

sudo apt-get install libjsoncpp-dev

https://i-blog.csdnimg.cn/direct/f2fdce02c83844739c174a7f6c59d16c.png

https://i-blog.csdnimg.cn/direct/992f63c9d9c841f3a5976931ea34a73f.png


方法一:

git clone https://github.com/chenshuo/muduo.git

方法二:

在我的gitee下在muduo库。

直接点击下面访问仓库。

步骤1:克隆代码到本地

步骤2:unzip 解压压缩包

unzip muduo-master.zip

步骤3:进入muduo-master

步骤4:下载指定的boost库

sudo apt-get install libz-dev libboost-dev

步骤5:运行build.sh脚本。

./build.sh

步骤6:

./build.sh install

执行这个命令,muduo库本身不依赖全部的boost库的组件,只依赖boost::any模块,所以不需要全量下载boost库,指定下载开发库就好了。

不要求是:

libboost-all-dev

https://i-blog.csdnimg.cn/direct/9c01fe5779f24da19f7b902ecd1ba839.png