What Is The Difference Between Using Zmq Pub With .connect() Or .bind() Methods?
Solution 1:
There is no difference here (single publisher and subscriber), but in other scenarios (multi publishers or subscribers), there is a difference depending on your policy:
- i.e. suppose that there are two clients (Machine1, Machine2) and a Server.
Each client must publish data using
ZMQ
, and the Server must subscribe that data from Machine1 and Machine2:
Machine1 --> has a publisher (with
.connect(Server IP)
)Machine2 --> has a publisher (with
.connect(Server IP)
)Server --> has a subscriber (with
.bind(Server IP/Self IP)
)
As you can see in the mentioned scenario we used the second case in the question.
- Whereas, if we have two subscribers and a publisher, we must place the
.bind()
method in the publisher and place.connect()
method in the subscribers (first case in the question).
[NOTE]:
Solution 2:
Operational-level difference, there is none.
Setup perspective difference - .bind()
method need not know the actual addresses ( using wildcard-expansio tricks et al ), .connect()
method has to know a target address to which it will start trying to .connect()
-to.
Transport-class / Scalable Formal Communication Pattern Archetype - there are cases, when some order of instantiation / becoming RTO is mandatory for proper archetype service, so, yes, there are differences, when one, .bind()
has to become RTO earlier, before any remote .connect()
may have a chance to succeed.
Add-on specific features available for configuring the .bind()
side - are the last principal set of differences, where some more recent ZeroMQ API versions 3.2+ started to add some new access-control and similar defensive options for the .bind()
-side node, so as to help manage plethora of risks once going into public internet exposed modus operandi.
Post a Comment for "What Is The Difference Between Using Zmq Pub With .connect() Or .bind() Methods?"