[zeromq-dev] Best way to punt on a ZMQ_REQ?

Matt Weinstein mattweinstein at gmail.com
Thu Jun 10 22:16:56 CEST 2010


I'm using a ZMQ_REQ socket to send a query to a server, and I need to  
timeout if the response isn't received on time.

The best way would seem to be to zmq::poll with a timeout (not working  
for me at present, see my prior email).  Alternatively I could use  
ZMQ_NOBLOCK and a sleep loop, but that's ugly.

In any event, after I go away I'm left with a socket that's in the  
wrong state for the next request, which may arrive before the last  
request.  I don't see any way of resetting a socket, so I'm presuming  
my best bet is to tear down the socket and use a new one for the next  

Meanwhile, what happens to the server at the other end of the request,  
still holding pieces of state through a zmq::queue via a ZMQ_XREP  

I'm presuming tearing down the ZMQ_REQ side will just purge the  
relevant data, and the reply will go into the ether?  Or will the  
server get an EFSM or some such when it tries to send() back on its  
REP stream?




More information about the zeromq-dev mailing list