CZMQ 库为和类(和)提供nowait选项,但没有像. 有什么解决办法吗?而不是与标志一起使用。我的代码是:zstrzframezstr_recv_nowait()zframe_recv_nowait()zmsg_recv_nowait()zmq_msg_recvZMQ_DONTWAIT
zmq_pollitem_t items[] = { {sock, 0, ZMQ_POLLIN, 0} };
zmq_poll(items, 1, 10);
/* now receive all pending messages */
while (1) {
zmsg_t *msg = zmsg_recv(sock); /* this will block after the last message received */
/* consume message here */
}
/* sending bunch of messages */
我正在做异步REQ/REP。发送多个请求然后在它们准备好时接收回复。此代码将阻止我的应用程序。zmq_poll对我来说,做一个,收到一条消息等等似乎很难看……因为当zmq_poll返回时,其他回复已经到达。