How to implement UDP multicast Pub-sub with ZEROMQ (based on Golang)

Source: Internet
Author: User
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.

  1. PGM has a feature, that is, the sender of flow control, ZMQ is used in the setrate, remember to use before connect
  2. ZMQ will tidy up the package, so the scattered data will be combined into a message sent out (it is indeed intelligent network)
  3. Actual test ... 16Mbps traffic is not a problem at all
  4. When debug PGM is requiredexport PGM_MIN_LOG_LEVEL=TRACE

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.