A server node can bind to many endpoints (that is, acombination of protocol and address) and it can do this using a single socket.This means it will accept connections across different transports:
zmq_bind(socket, "tcp://*:5555");
zmq_bind (socket, "tcp://*:9999");
zmq_bind (socket, "inproc://somename");
服务器可以同时监听多个端口,比如服务器监听端口5555和6666,那么客户端一调用zmq_connect(req,"tcp://127.0.0.1:6666")建立连接,客户端二调用zmq_connect(req,"tcp://127.0.0.1:55555")建立连接.服务器可以同时和这两个客户端进行通信
下面给出一个例子:
server.cpp代码:
#include "zmq.h"
#include <stdio.h>
#include <string.h>