[zeromq-dev] Custom HWM behavior

Bernt Habermeier bernie at fliptrack.com
Sat Aug 20 01:25:27 CEST 2011

Awesome.  Looks like everything is working.  I had always been using
ZMQ::MODE_NOBLOCK in my send, but I thought it blocked regardless.  I
probably was just confused by the fact that it was blocking at exit.

So now I'm setting SOCKOPT_LINGER, SOCKOPT_HWM -- and (as always)
ZMQ::MODE_NOBLOCK in my send, and everything looks to behave exactly how I
need it, and I can happily use the pattern I believe is correct for my


On Fri, Aug 19, 2011 at 10:08 AM, Ian Barber <ian.barber at gmail.com> wrote:

> On Fri, Aug 19, 2011 at 5:21 PM, Bernt Habermeier <bernie at fliptrack.com>wrote:
>> To be clear, the option I would want is to be able to set a socket option
>> (or something like that) that indicates:
>>    - If we hit HWM condition, drop data
>>    - If we have data at process exit, drop data.
>> Alternatively, if I can query the queue length of messages that are unsent
>> from the API, instead of blindly adding the event to be sent over the
>> socket, I could drop it before it ever hits ZMQ.  Does this exist?  Of
>> course, I'd still have to have the ability to "drain the data" to be sent
>> out at process exit -- I don't want the process to hang / wait indefinitely.
> I think you have the tools you need in the API - look at the ZMQ_LINGER
> sockopt for termination, and for sending data you can either use send with
> the flag ZMQ_NOBLOCK to guarantee no blocking, or poll the socket first to
> see whether a message would block on send.
> Ian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110819/472521ad/attachment.htm>

More information about the zeromq-dev mailing list