[zeromq-dev] zmq_send and zmq_close synchronization

Martin Sustrik sustrik at 250bpm.com
Wed Mar 10 08:37:40 CET 2010


> When zmq_send is called, it returns immediately which is good. AFAIK,
> the message will be eventually sent out by the IO thread.
> If zmq_close is called on the socket before the message got sent out 
> from the IO thread, the pending message seem to get removed without 
> getting sent out.
> Is there any way to wait for the send of all the message associated 
> with a socket to finish?

No. It would result in deadlock if the other party is unavailable.
Moreover, what you want to wait for is the acknowledgement that the
other party had received the messages and taken
responsibility for processing them. Simply pushing the data to the
network and exiting would mean nothing. The data can still be lost

Thus, my advise would be to send an application level ACK message to the
sender saying "ok, you can terminate now, all the messages were received".


More information about the zeromq-dev mailing list