具有EPGM的ZeroMQ PUB/SUB无法接收同一主机上的进程发送的消息 [英] ZeroMQ PUB/SUB with epgm not able to receive messages sent by process on the same host
问题描述
我所有的进程都有两个套接字,一个PUB和一个SUB,它们都使用相同的多播地址和端口.
All my processes have two sockets, one PUB and one SUB, and they all use the same multicast address and port.
例如,PUB将执行此操作:
For example, PUB will do this:
bind("epgm://239.192.1.1:5555")
bind("epgm://239.192.1.1:5555")
SUB将执行此操作:
SUB will do this:
connect("epgm://239.192.1.1:5555")
setsockopt(ZMQ_SUBSCRIBE,",0); //订阅所有内容
connect("epgm://239.192.1.1:5555")
setsockopt(ZMQ_SUBSCRIBE, "", 0); //subscribe everything
然后,PUB将通过调用zmq_send发送消息,而SUB将通过调用zmq_poll接收消息并执行非阻塞zmq_recv.
PUB will then send message by calling zmq_send, and SUB will receive by calling zmq_poll and do Nonblocking zmq_recv.
当我在两个不同的主机上运行两个进程时,它工作得很好.但是,如果我在同一主机上运行它们,则发送工作正常,但是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.
所以我想知道这是因为zeromq(或openpgm)进行了某种过滤,以便从与接收套接字具有相同host:port的套接字发送的消息不会传递到接收套接字吗?
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?
推荐答案
我怀疑ZeroMQ没有启用多播回送,或者您可能应该通过ZeroMQ API自己进行某种操作,而实际上不是.
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.
这篇关于具有EPGM的ZeroMQ PUB/SUB无法接收同一主机上的进程发送的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!