1. 什么是Waltham
Waltham IPC Libray 是一个网络IPC库,在协议和API方面都类似于Wayland。协议也是使用XML来描述的。在构建时,可以使用生产器工具将XML转化成C语言代码。
Waltham协议的设计完全与Wayland扩展相同(使用过Wayland,并做过相关接口扩展的,可以很容易理解),但是Waltham协议接口不需要文件描述做接口参数(这点与Wayland 协议接口是有区别的)。
2. 特点
- (1) 协议框架被设计成完全异步的和面向对象的。
- (2)如果需要同步调用,需要编写专门的协议定义。
- (3)不支持加密,不建议在不可信网络中使用。
- (4)Waltham使用TCP套接字进行通信
- (5)Waltham无法发送文件描述符
- (6)不支持在线程之间共享对象
许多的差异特点也是在与Wayland一块使用过程中总结出来的。
3. 官方网址
https://github.com/waltham/waltham
https://waltham.github.io/waltham/index.html
4. 源码下载与使用
首先需要下载源码,进入源码根目录(需要先安装autoconf):
$ ./autogen.sh
$ make
编译完成后,会生成测试demo程序(server和client)
测试,首先启动server:
$ ./tests/server
另外在开启一个终端,启动client:
$ ./tests/client
The client runs for about five seconds excercising the protocol and exits automatically. The server can be stopped with ctrl+c
.
如果你想使用 GDB or Valgrind启动server和client程序:
$ libtool --mode=execute gdb ./tests/server
$ libtool --mode=execute valgrind -v --leak-check=full --show-reachable=yes --track-origins=yes --num-callers=30 ./tests/server
编译完成后,我们就可以使用waltham了。找到相关的libwaltham库和头文件,我们就可以创建相关的server端和client端代码,可以参考上述提到的demo程序。