[zeromq-dev] flushing (again)

Andrew Hume andrew at research.att.com
Sun Apr 3 19:01:32 CEST 2011


thanks!
i had already prepared for this by have an application specific term function
to clean up all the sockets; but had forgotten to add the zmq_term.


On Apr 3, 2011, at 8:32 AM, Martin Sustrik wrote:

> Hi Andrew,
> 
>> i am running 2.1.1.
>> 
>> i have a program which essentially does
>> 
>> // sock has been opened as a ZMQ_PUSH over tcp
>> msendstr(sock, "exit");
>> ret = zmq_close(sock);
>> assert(ret == 0);
>> exit(0);
>> 
>> if i run this, then i've never seen the message get to teh other end.
>> if i insert a sleep(1) BEFORE the exit (and AFTER the zmq_close), it
>> always arrives at its dest.
> 
> The problem is that you don't terminate the library (zmq_term).
> 
> zmq_close is an async operation that starts shutdown of the socket and 
> returns immediately. The shutdown -- including the sending of pending 
> messages -- continues in the backgroud. If you exit the process at this 
> point, the background thread won't get a chance to push the messages to 
> the network.
> 
> So, instead of exiting, just call zmq_term(), which is an blocking 
> operation and waits for all pending messages to be sent.
> 
> Unfortunately, 0MQ is implemented in user space and thus doesn't allow 
> for nice, transparent, TCP-like flush of pending messages.
> 
> Martin
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev


------------------
Andrew Hume  (best -> Telework) +1 623-551-2845
andrew at research.att.com  (Work) +1 973-236-2014
AT&T Labs - Research; member of USENIX and LOPSA




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110403/af2d9325/attachment.htm>


More information about the zeromq-dev mailing list