Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is There any way to achieve a ZeroMQ fullduplex channel?

Tags:

python

c#

zeromq

The project is to build a messaging mechanism between a Python and C# program via ZeroMQ .

I want messages to be able to travel in/out from both ends at any time, which is NOT a basic request-reply model a.k.a. REQ/REP.
One way I can think of is to build a PUB/SUB model on two ports, i.e. two one way channels.
Is there any method to get a real duplex channel?

like image 658
joe Avatar asked Oct 26 '25 05:10

joe


2 Answers

There are several ways to do this with ZeroMQ. I suggest using a DEALER/ROUTER socket pair:

  • Choose one program to be the "server", the other the "client".
  • The server will bind a ROUTER socket on a port.
  • The client will connect a DEALER socket to the server's ROUTER port. (Note: this implies that the client must know the server's IP and port in advance.)

At this point the client can send messages to the server, but the server has no way to send to the client.

  • The client sends a "HELLO" message to the server.

The server will receive a message that includes the client's address and the HELLO message. Now the server can send messages to the client using the client's address.

DEALER/ROUTER is considered an "advanced" socket pair in ZeroMQ. My description here is very high level. You'll really need to read the docs to get the most out of ZeroMQ.

like image 108
colini Avatar answered Oct 28 '25 18:10

colini


Oh yes, Sir!

Use the PAIR-PAIR or even the XREQ-XREP ought make it.

The best next step is to carefully read the respective Scalable Formal Communication Pattern archetypes' access-points' API documentation, so as to cross-check, that all pieces of pre-wired behavioural logic meet your Project needs and voilá, harness them in your messaging setup and tune-up the settings so as to meet you performance and latency needs.

That is this simple ( thanks to all the genuine knowhow hidden in these builtins ).

Using for years this very sort of inter-platforms integration among Python + C/MQL4 and other computing nodes, so well worth one's time to learn the powers and strengths of ZeroMQ.

like image 28
user3666197 Avatar answered Oct 28 '25 18:10

user3666197



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!