[zeromq-dev] bind vs connect for ZMQ_PUB socket

Martin Sustrik sustrik at 250bpm.com
Mon Mar 8 08:08:37 CET 2010

Chris Wong wrote:
> In the documentation of pub/sub multicast example,
> http://www.zeromq.org/area:docs-v20#toc13
> Both PUB and SUB socket always have zmq_connect call.
> In perf/c/local_thr.c and perf/c/remote_thr.c, the SUB socket always
> call zmq_bind and the PUB socket always call connect.
> In the tcp PUB/SUB example in the documentation, PUB socket calls
> bind while SUB socket calls connect.
> It's getting very confusing. :-)  Can someone help clarify the
> semantics behind zmq_bind and zmq_connect?  I thought they were close
> to the socket API, now I'm not so sure.

Bind and connect make sense only for transports that have asymmetric 
connecting model, i.e. one peer waits for connection, while the second 
peer creates the connection.

For symmetric and/or connectionless transports - such as PGM - the both 
functions have exactly the same semantics.


More information about the zeromq-dev mailing list