[zeromq-dev] Send queue after socket close

Lindley French lindleyf at gmail.com
Tue Jan 14 12:34:00 CET 2014


According to the docs, by default if a socket is closed, its send queue
will still be sent. However, the behavior I'm seeing casts some doubt on
this.

What I'm designing is a simple test-case, so its real-world applicability
is questionable, but I'd like to understand what is going on.

I have two threads. One thread has a DEALER and the other a ROUTER. The
DEALER connects to the router over TCP. The DEALER spews 10,000 messages at
the ROUTER, then closes. The ROUTER reads 10,000 messages, and then closes.

What's actually happening is fewer than 10,000 messages are arriving
(around 9,500, on average, but it varies), so the ROUTER's thread is
hanging. I'm trying to understand why. I can tell from my logs that the
DEALER finishes sending some time before the last successful receive by the
ROUTER. My speculation is that I'm closing the DEALER too soon, and its
queued messages aren't all being sent.

One practical solution would be for the ROUTER to send back a "THANKS"
message to the DEALER once it has everything, and not allow the socket to
close until then. I would like to understand the subtleties of the
implementation, though.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140114/f90e136b/attachment.htm>


More information about the zeromq-dev mailing list