[zeromq-dev] Multiple connects with a ZMQ_REQ socket appears not to work

Justin Karneges justin at karneges.com
Sat Feb 24 02:25:21 CET 2018


On Fri, Feb 23, 2018, at 4:53 PM, Mark via zeromq-dev wrote:
> As I mentioned previously the docs on REQ/REP state:
> 
>    "If no services are available, then any send operation on the
>     socket shall block until at least one service becomes available."
> 
> but the send() doesn't block in this situation. As you said earlier
> the message is queued and sent async with send() returning to the
> caller.
> 
> I also mis-interpreted the docs to imply that when "at least one
> service becomes available" that any queued messages would go to that
> service, but that's not the case as the round-robin decision is only
> made once on the call to send() - not during the async sending
> process.
> 
> Anyhoo, it's all good now that I know better.

Yeah one thing that got me when I started out with ZeroMQ is understanding that queues only exist in the context of known peers, and that a zmq socket doesn't have a master queue or anything that exists in the absence of known peers. This is why writing to a socket that is binding but has no peers will block.

I say "known peers" rather than "peer connections" because you get a queue once you attempt to connect to a peer, even if that connection is not yet established.

Justin



More information about the zeromq-dev mailing list