[zeromq-dev] ask again for question "recv in REQ client blocks forever if XREP server dies"

aple mengxu at staff.sina.com.cn
Tue Aug 23 08:03:11 CEST 2011


hi there,

I met the same problem with Troy, and i'm using 2.1.8 0mq version.
I tried zmq_poll as said in
"http://comments.gmane.org/gmane.network.zeromq.devel/6285" with
hwclient/hwserverexample to let client poll before recv any message. But
I always get poll timeout.

here below is the pseudo-code.

client:
zmq::context_t context (1);
zmq::socket_t socket (context, ZMQ_XREQ);
socket.connect ("tcp://localhost:55555");
socket.send (request);
zmq::message_t reply;
zmq::pollitem_t items[] = { { socket, 0, ZMQ_POLLIN, 0 } };
int ret = zmq::poll (items, 1, 1500000);
if (items[0].revents & ZMQ_POLLIN) {
....
socket.recv (&reply);
}

server:
zmq::context_t context (1);
zmq::socket_t socket (context, ZMQ_XREP);
socket.bind ("tcp://*:55555");
while (true) {
socket.recv(&request);
socket.send (reply);
}

waiting for ur reply.
BR/Shi.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110823/2c97f2ba/attachment.htm>


More information about the zeromq-dev mailing list