Search code examples
c++messagezeromqsend

Stop zmq message


When I use send and the addressee is not listening, zmq internally will keep trying until the message is delivered. Are there any way to stop this? For example, try for 5 seconds and stop? Thanks.


Solution

  • Try to use zmq_setsockopt and set the ZMQ_LINGER option (that is the timeout for subsequent operations).

    send can also use ZMQ_NOBLOCK to return immediately, but then subsequent close will still block, so the ZMQ_LINGER option is preferred.