This is a created article in which the information may have evolved or changed.
ZEROMQ has a pair of pub/sub socket types, but tutorials on the web generally focus on using the TCP version of ... Although the TCP version of the network can also be, but a little trouble, today I would like to introduce to you the ZEROMQ Pub/sub model based on PGM protocol first to compile the installation OPENPGM brewinstall libpgm and then ZMQ brew install zmq --with-pgm so ready for the environment, Here we need to understand the principle of the PGM network, very simple, such as the green is the sender, to the destination multicast address 239.192.0.1 port 3055 (thick black line) to send data, and then all the receivers listening to this port (receiver) received. It's so simple. And then write the code:
soc = zmq.NewSocket(zmq.PUB)soc.Connect("epgm://192.168.1.100;239.192.0.1:3055")soc.SendMessage("Hi")
Uh...... 192.168.1.100? This is the characteristics of PGM, you need to specify the name of the network card to send multicast packets, the average person can not remember the network card name ... So use the IP of this network card to indicate. P.S.
- PGM has a feature, that is, the sender of flow control, ZMQ is used in the setrate, remember to use before connect
- ZMQ will tidy up the package, so the scattered data will be combined into a message sent out (it is indeed intelligent network)
- Actual test ... 16Mbps traffic is not a problem at all
- When debug PGM is required
export PGM_MIN_LOG_LEVEL=TRACE