[zeromq-dev] Issue when using pub / sub after any other pair
Pavel Chlupáček
chlupacek at gmail.com
Thu May 19 16:11:16 CEST 2011
Martin this is the scala snippet:
it("Will correctly parse PUB/SUB pair") {
val zc = ZMQ.context(1)
val socketPub = zc.socket(ZMQ.PUB)
val socketSub = zc.socket(ZMQ.SUB)
socketPub.bind("ipc://foo-S")
socketSub.subscribe(Array())
socketSub.connect("ipc://foo-S")
try {
val poller = zc.poller(1)
val idxSub = poller.register(socketSub, ZMQ.Poller.POLLIN | ZMQ.Poller.POLLERR)
val zm = ZMQMessage("Test", serializer).sendTo(socketPub)
assert(poller.poll(1000) > 0 && poller.pollin(idxSub), "NO message in queue? ")
ZMQMessage.readNext(socketSub, serializer) match {
case Some(zmqm) => {
assert(zmqm.addresses.isEmpty, "Addresses present?")
assert(zmqm.content == "Test", "Content is not same")
}
case None => fail("Message was not read")
}
} finally {
socketPub.close()
socketSub.close()
zc.term()
}
}
so I send on BIND side of connection, which is Pub side as well.
I get false assertion on "NO message in queue?"
Does that makes a sense?
P.
On May 19, 2011, at 4:05 PM, Martin Sustrik wrote:
> On 05/19/2011 04:03 PM, Pavel Chlupáček wrote:
>
>> Well doesn't seem so, as it is in one single thread. So the bind, connect, send, rcv after each other in sequence.
>
> Note that connect is async. Are you sending on bind or connect side of the connection?
>
> Martin
More information about the zeromq-dev
mailing list