//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
Print("[REP] Unbinding MT4 Server from Socket on Port " + (string)REP_PORT + "..");
repSocket.unbind(StringFormat("%s://%s:%d", ZEROMQ_PROTOCOL, HOSTNAME, REP_PORT));
Print("[SUB] Unbinding MT4 Server from Socket on Port " + (string)SUB_PORT + "..");
subSocket.disconnect(StringFormat("%s://%s:%d", ZEROMQ_PROTOCOL, "192.168.3.88", SUB_PORT));
//+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- Print("[REP] Unbinding MT4 Server from Socket on Port " + (string)REP_PORT + ".."); repSocket.unbind(StringFormat("%s://%s:%d", ZEROMQ_PROTOCOL, HOSTNAME, REP_PORT)); Print("[SUB] Unbinding MT4 Server from Socket on Port " + (string)SUB_PORT + ".."); subSocket.disconnect(StringFormat("%s://%s:%d", ZEROMQ_PROTOCOL, "192.168.3.88", SUB_PORT));
//不需要下面的关闭和销毁上下文,如果加上的话 不能正常反初始化 只需要上方的代码即可 //这行代码调用 ZeroMQ 上下文对象的 shutdown 方法,用于关闭 ZeroMQ 上下文。上下文对象是 ZeroMQ 库中的一个重要对象,它负责管理套接字、线程和其他资源。 //context.shutdown(); //这行代码调用 ZeroMQ 上下文对象的 destroy 方法,用于销毁 ZeroMQ 上下文。参数 0 表示立即销毁上下文,释放所有资源。 // context.destroy(0); EventKillTimer();
} 一个不太理解的事情 就是 如果使用 context.shutdown(); context.destroy(0); 则 如果切换图标周期,就不能再使用了,除非重启客户端,如果 不加这两句 则切换图标周期没有问题。 关闭和 销毁context 不是在 别的语言中 常规的操作吗?