[zeromq-dev] Question to ZMQ_LINGER

Martin Sustrik sustrik at 250bpm.com
Fri Feb 25 12:55:39 CET 2011

Hi Andreas,

> thanks for the new version with a lot of good new features. But I
> have a question about ZMQ_LINGER. My test code breaks now at many
> points or hang. Of course, I have to use ZMQ_LINGER now to avoid
> zmq_term() to hang indefinitely for some tests, I read this in the
> manual. But now I run into another problem. I repeat the sequence
> (socket with linger option, bind, close) frequently, without send or
> receive action. Now I get errors "Addreass already in use", I guess
> because zmq_close() is not blocking for the lingering.
> Is there a way to synchronize (block) zmq_close() for thde pending
> linger?

zmq_close() is async, so only way to make sure that associated resources 
are closed is to close the whole context using zmq_term(). That 
operation blocks until all the sockets are fully closed.


More information about the zeromq-dev mailing list