libevent+zeromq
来源:互联网 发布:道教知乎 编辑:程序博客网 时间:2024/06/05 12:47
ZeroMq with libevent (cont)
I have just discovered the reason why my libevent program did not receive any more ZeroMq messages after the first one. It seems that, after creating the ZeroMq socket, you have to read until you get a EAGAIN error or you will not set the socket events in the right state. If you don’t do so, the idea libevent and ZeroMq have about that socket will not match, so your program will not receive/send anything.
From this thread:
The socket is initially considered ready for reading & writing. Given that ZMQ_FD is edge triggered, you won’t get next event unless you fail to send/recv a message.
So, when you create a socket, you have to do something like this:
zsocket = new zmq::socket_t (*ZMqLink::m_pZContext, ZMQ_XREQ);/* read until EAGAIN */while (TRUE){ zmq::message_t msg; bool more = zsocket->recv(&msg, ZMQ_NOBLOCK); if (!more) break;}/* now we can get the zsocket fd */int fd = (-1);size_t fd_size = sizeof(fd);zocket->getsockopt(ZMQ_FD, &fd, &fd_size);/* ... and register it with libevent for EV_READ */
原文地址:http://inercia.tumblr.com/post/3600122381/zeromq-with-libevent-cont
- libevent+zeromq
- ZeroMQ + libevent in PHP
- zeromq
- zeromq
- zeroMQ
- Zeromq
- zeroMQ
- zeroMQ
- zeromq
- zeromq
- zeromq
- ZeroMQ
- zeromq
- ZeroMQ
- ZeroMQ
- ZeroMQ
- ZeroMQ
- ZeroMQ
- 在VMWare Workstation上使用RedHat Linux安装和配置Hadoop群集环境03_配置虚拟机之间SSH无密码登录
- gdb用法(三) 调试其他正在运行的进程
- Jquery实用工具集
- eval进行json字符串转换时报缺少缺少“;”的解决方案
- form2json实例
- libevent+zeromq
- java代码重构------代码艺术
- MyEclipse使用经验总结
- NSDate处理
- ArcGIS几种数据格式
- TOMCAT中如何自动加载程序
- filter过滤器实现过滤非法文字
- 绘制柱形图(对排序数据进行分析)
- 性能调优三步走