[zeromq-dev] conventions in bindings

Martin Lucina martin at lucina.net
Wed Feb 1 03:16:13 CET 2012


On Tue, 31 Jan 2012 18:06:06 -0800
MinRK <benjaminrk at gmail.com> wrote:

> On Tue, Jan 31, 2012 at 17:23, Martin Sustrik <sustrik at 250bpm.com> wrote:
> 
> > Hi,
> >
> >
> >  * SUB sockets default to SUBSCRIBE("") instead of None
> >>
> >
> > This becomes a problem with 3.0 and subscription forwarding. The problem
> > occurs when you don't want to subscribe to all messages. You open a socket
> > and unsubscribe from "". However, between the two operations you can be
> > overloaded by huge amount of irrelevant messages from the publisher.

In fact you could get the same problem with 2.x, but with subscription
forward it gets worse.

To put this into perspective, imagine you connect to a firehose feed of
twitter using ZeroMQ. If your default SUB socket behaviour is SUBSCRIBE
("") then in all likelyhood you've probably just DoSed yourself.

ZMQ_SUB defaulting to SUBSCRIBE("") is broken behaviour, period.

> >
> >
> >  * LINGER is a property of the Context, and sets a default value for its
> >> sockets, which is 0 by default, instead of -1
> >>
> >
> > The problem with default LINGER equal to 0 is that following program
> > doesn't send any message (the socket is destroyed before connection is
> > established):
> >
> >   s = zmq_socket (ctx, ZMQ_PUSH);
> >   zmq_connect ("tcp://server0001:5555");
> >   zmq_send (s, "ABC", 3, 0);
> >   zmq_close (s);
> >
> > That's an extremely unintuitive behaviour.
> >
> > If default linger time of infinity is causing troubles I would rather
> > suggest going for something like 1 second.
> 
> 
> It sounds like the recommendation here is that czmq should stop doing what
> it does, rather than other bindings following suit.

+1

Both the "ZMQ_LINGER defaults to inifinity" and "SUB socket defaults to
no subscriptions" were discussed to death on this list a year or so
ago. I can dig up pointers to the threads if you want.

I would recommend that language bindings follow the libzmq core
behaviour.

-mato
-- 
Martin Lucina <martin at lucina.net>



More information about the zeromq-dev mailing list