Troubles with zmq_bind() in ZeroMQ binding for MQL4 language

匿名 (未验证) 提交于 2019-12-03 03:04:01

问题:

I am working on MT4 and used wrapper mql4zmq.dll as given in link

https://github.com/AustenConrad/mql4zmq 

As I have followed all instruction and successfully loaded DLL as well as lib file at specific locations from pre-compiled. But it can not bind or connect with socket through zmq_connect(,) or zmq_bind(,). Please some one help me to solve this problem. I am posting my code here

// Include the libzmq.dll abstraction wrapper. #include <mql4zmq.mqh>  //+------------------------------------------------------------------+ //| variable definitions                                             | //+------------------------------------------------------------------+ int speaker,listener,contextt;  //+------------------------------------------------------------------+ //| expert initialization function                                   | //+------------------------------------------------------------------+ int init()   { //----    int major[1];int minor[1];int patch[1];    zmq_version(major,minor,patch);    Print("Using zeromq version " + major[0] + "." + minor[0] + "." + patch[0]);     Print(ping("Hello World"));     Print("NOTE: to use the precompiled libraries you will need to have the Microsoft Visual C++ 2010 Redistributable Package installed. To Download: http://www.microsoft.com/download/en/details.aspx?id=5555");     contextt = zmq_init(1);    speaker = zmq_socket(contextt, ZMQ_PUB);    listener = zmq_socket(contextt, ZMQ_SUB);     // Subscribe to the command channel (i.e. "cmd").      // NOTE: to subscribe to multiple channels call zmq_setsockopt multiple times.    zmq_setsockopt(listener, ZMQ_SUBSCRIBE, "");      if (zmq_bind(speaker,"tcp://127.0.0.1:5555") == -1)     {       Print("Error binding the speaker!");       return(-1);      }  

There is problem in

if ( zmq_bind( speaker, "tcp://127.0.0.1:5555" ) == -1 ) 

It returns -1 and does not bind.

I have tried every possible thing to solve this mystery but failed.

Please let me know if I am mistaken!!!

回答1:

Yes, address/port-in use may block .bind() / .connect()

As solved in the comments above, there is another post with a similar solution of the same root-cause why the well-formed ZeroMQ-code was still not able to .bind()

Address/port release/re-use is O/S-dependent resource-management issue. Be carefull once developing for a production-grade operations.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!