1 linux
下载libzmq source code:https://github.com/zeromq/libzmq/tree/v4.3.4
编译
sudo apt-get install libtool pkg-config build-essential autoconf automake # 安装依赖
- ./autogen.sh
- ./configure --without-libsodium
- libsodium - 加密库
- make -j4
- sudo make install
- sudo ldconfig
示例
server
#include <zmq.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
int main (void)
{
void *context = zmq_ctx_new ();
void *responder = zmq_socket (context, ZMQ_REP);
int rc = zmq_bind (responder, "tcp://*:5555");
assert (rc == 0);
while (1) {
char buffer [10];
zmq_recv (responder, buffer, 10, 0);
printf ("Received Hello\n");
sleep (1); // Do some 'work'
zmq_send (responder

本文详细介绍了如何在Linux系统中为x86架构和ARM64架构编译libzmq库,并通过示例展示了客户端与服务器的通信过程。涉及apt-get安装依赖、交叉编译及实际运行步骤。
最低0.47元/天 解锁文章
1457

被折叠的 条评论
为什么被折叠?



