title: zeromq: how to prevent infinite wait?
body: <p>I just got started with ZMQ. I am designing an app whose workflow is:</p>
  
  <ol>
  <li>one of many clients (who have random PULL addresses) PUSH a request to a server at 5555</li>
  <li>the server is forever waiting for client PUSHes. When one comes, a worker process is spawned for that particular request. Yes, worker processes can exist concurrently.</li>
  <li>When that process completes it's task, it PUSHes the result to the client.</li>
  </ol>
  
  <p>I assume that the PUSH/PULL architecture is suited for this. Please <strong>correct me</strong> on this.</p>
  
  <hr>
  
  <p>But how do I handle these scenarios?</p>
  
  <ol>
  <li>the client_receiver.recv() will wait for an infinite time when server fails to respond.</li>
  <li>the client may send request, but it will fail immediately after, hence a worker process will remain stuck at server_sender.send() forever.</li>
  </ol>
  
  <p>So how do I setup something like a <strong>timeout</strong> in the PUSH/PULL model?</p>
  
  <hr>
  
  <p><strong>EDIT</strong>: Thanks user938949's suggestions, I got a <strong>working answer</strong> and I am sharing it for posterity.</p>