[zeromq-dev] [Q] bind and connect multiple times

Chuck Remes cremes.devlist at mac.com
Sat May 15 21:32:07 CEST 2010


Both zmq_bind and zmq_connect have a paragraph similar to this in their docs:

> A single socket may be connected to an arbitrary number of peer addresses using
> _zmq_connect()_, while also having an arbitrary number of local addresses
> assigned to it using _zmq_bind()_.


I admit I don't understand how a socket can be a parameter to multiple bind or connect calls. Perhaps this makes sense to folks who have been using sockets for a long time, but most of my networking code has dealt with higher level abstractions so this is my first real exposure to the nitty-gritty details at the bottom.

I learn well by example. Can someone provide a reasonable real-world example where one would call zmq_bind (or zmq_connect) multiple times on the same socket? Does it matter what kind of socket it is, e.g. REQ, REP, PUB, DOWNSTREAM, etc.? Does this concept make sense for some of those socket types and not for others?

I read the man pages for bind and connect on my OSX box but they weren't too enlightening. The bind call was silent on the issue of multiple calls. The connect man page did mention it was acceptable to call connect multiple times but it implied that it broke the old connection in favor of setting up a new one each time it was called.

Anyway, thanks in advance for any and all clarifications.

cr




More information about the zeromq-dev mailing list