zeromq: how to prevent infinite wait?

前端 未结 4 1534
难免孤独
难免孤独 2020-12-12 10:58

I just got started with ZMQ. I am designing an app whose workflow is:

  1. one of many clients (who have random PULL addresses) PUSH a request to a server at 5555
4条回答
  •  一整个雨季
    2020-12-12 11:29

    The send wont block if you use ZMQ_NOBLOCK, but if you try closing the socket and context, this step would block the program from exiting..

    The reason is that the socket waits for any peer so that the outgoing messages are ensured to get queued.. To close the socket immediately and flush the outgoing messages from the buffer, use ZMQ_LINGER and set it to 0..

提交回复
热议问题