问题
All my processes have two sockets, one PUB and one SUB, and they all use the same multicast address and port.
For example, PUB will do this:
bind("epgm://239.192.1.1:5555")
SUB will do this:
connect("epgm://239.192.1.1:5555")
setsockopt(ZMQ_SUBSCRIBE, "", 0); //subscribe everything
PUB will then send message by calling zmq_send, and SUB will receive by calling zmq_poll and do Nonblocking zmq_recv.
It works perfectly fine when I run two processes on two different hosts. But if I run them on the same host, the send works but recv never receives anything.
I know the send works because if I have the third process run on a different host I'll receive message from both of the first two processes, while the first two processes only receive message sent by the third process.
So I wonder is this because zeromq (or openpgm) does some kind of filtering so messages sent from the socket with same host:port as receiving socket will not be passed to receiving socket?
回答1:
I suspect ZeroMQ is not enabling multicast loopback, or maybe you are supposed to do it yourself somehow via the ZeroMQ API and you aren't.
回答2:
use NORM instead of PGM -> http://zeromq.org/topics:norm-protocol-transport - works well with loopback
来源:https://stackoverflow.com/questions/19141866/zeromq-pub-sub-with-epgm-not-able-to-receive-messages-sent-by-process-on-the-sam