我正在使用MT4并使用链接
中给出的包装器mql4zmq.dll
https://github.com/AustenConrad/mql4zmq
因为我已经遵循了所有指令并在预编译的特定位置成功加载了DLL
和lib
文件。但通过 bind
或 {{套接字不能 connect
或 zmq_connect(,)
1}} 即可。请有人帮我解决这个问题。我在这里发布我的代码
zmq_bind(,)
中存在问题
// 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);
}
返回 if ( zmq_bind( speaker, "tcp://127.0.0.1:5555" ) == -1 )
,但 -1
。
我已尽力解决这个谜团但却失败了。
如果我弄错了,请告诉我!
答案 0 :(得分:0)
address/port
- 正在使用中可能阻止.bind() / .connect()
正如上面的评论所解决的那样
another post with a similar solution of the same root-cause why the well-formed ZeroMQ-code was still not able to .bind()
地址/端口释放/重用是与O / S相关的资源管理问题。一旦开始进行生产级操作,请小心。