[zeromq-dev] Send queue after socket close

Pieter Hintjens ph at imatix.com
Tue Jan 14 16:07:02 CET 2014


Ah, the default is indeed -1, meaning infinite linger, and no message loss.

If you use CZMQ it defaults to 0.

Are you using CZMQ or the native C API? The DEALER close should wait
until all messages are sent.

Still, I'd not trust it; even "sent" can mean "delivered to socket
layer but still in transit".

-Pieter

On Tue, Jan 14, 2014 at 3:29 PM, Lindley French <lindleyf at gmail.com> wrote:
> Perhaps I misinterpreted this sentence on the zmq_close() page:
> "The default setting of ZMQ_LINGER does not discard unsent messages"
>
>
> On Tue, Jan 14, 2014 at 8:47 AM, Pieter Hintjens <ph at imatix.com> wrote:
>>
>> On Tue, Jan 14, 2014 at 12:34 PM, Lindley French <lindleyf at gmail.com>
>> wrote:
>>
>> > 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.
>>
>> Where is this stated? Afaik the socket pipes (with messages) are
>> destroyed when the socket is destroyed, which will wait for the LINGER
>> time set on that socket, if there are messages waiting to be 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.
>>
>> Indeed, that's what you'd want to do. Closing the socket will drop an
>> undefined messages in flight unless you set infinite linger, which can
>> lead to your application blocking.
>>
>> -Pieter
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>



More information about the zeromq-dev mailing list