[zeromq-dev] [Q] bind and connect multiple times
Chuck Remes
cremes.devlist at mac.com
Sun May 16 05:39:36 CEST 2010
On May 15, 2010, at 2:49 PM, Pieter Hintjens wrote:
> On Sat, May 15, 2010 at 9:32 PM, Chuck Remes <cremes.devlist at mac.com> wrote:
>
>> 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.
>
> So standard sockets are 1-to-1, whereas 0MQ creates n-to-n sockets.
> This lets us implement messaging patterns in the socket layer (i.e. in
> 0MQ). Standard sockets implement a single pattern (peer to peer)
> where the network connection is the same thing as the socket. 0MQ
> sockets abstract the connections (hide them) so that one socket can
> exist as N connections, and as developer you don't really care.
>
> 0MQ adds the notion of socket type, defining what specific messaging
> pattern you want to use at both ends (publishers and consumers).
>
> Does this help?
Yes, this helps.
So I was correct to assume that this doesn't make sense for all socket types. For example, there is no point in having a REQ socket connect to multiple addresses. It sends one request and expects a single reply. On the flip side, a REP socket only binds once and never calls connect on anything.
We would probably only see multiple connect/bind calls on PAIR, SUB and DOWNSTREAM sockets.
Or am I still off-base?
cr
More information about the zeromq-dev
mailing list