is there anybody use ZeroMQ pub/sub?

 

thanks to Starry,his project https://www.mql5.com/en/code/9991 is great.

i wrote a simple python script like this:

import zmq
import time

cxt = zmq.Context()
s = cxt.socket(zmq.PUB)
s.bind("tcp://127.0.0.1:1900")

while True:
   s.send("CMD:Once")
   print "send once"
   time.sleep(1)

it works when python client scripts like that:

import zmq
import time

cxt = zmq.Context()
s = cxt.socket(zmq.SUB)

s.connect("tcp://127.0.0.1:1900")
s.setsockopt(zmq.SUBSCRIBE,'')

while True:
   msg = s.recv()
   print msg

print "Done"

The two script works perfectly.

then,i use mql4 to be the subscriber

#include <zmq_bind.mqh>

int sub,context,err;

int init()
{
   context = z_init(1);
   Print("using zeromq version "+z_version_string());

   sub = z_socket(context,ZMQ_SUB);
   z_connect(sub,"tcp://127.0.0.1:1900");
   z_subscribe(sub,"");

   while(true)
   {
      string message = z_recv(sub);
      Print("received:" + message);
   }

   return(0);
}

i can only get the two lines in Experts window

using zeromq version 2.0.10

received:

the receive msg is empty,where's the wrong?

 

  z_connect(sub,"tcp://127.0.0.1:1900"); 

Now MQL using Unicode string,

You could try to cope string in ANSI char buffer and give it in function by reference.