[zeromq-dev] XSUB/XPUB proper usage
Kenneth Adam Miller
kennethadammiller at gmail.com
Mon Dec 29 16:51:47 CET 2014
There's no really complete example in the guide with source for usage of an
XSUB/XPUB combination that I could find. So I have some questions:
Suppose the following is how I set up the XPub & XSub sockets:
_xpub = new zmq::socket_t(_context, ZMQ_XPUB);
_xpub->bind("inproc://killpub");
_xsub = new zmq::socket_t(_context, ZMQ_XSUB);
_xsub->bind("inproc://killsub");
//These sockets are created and bound in the constructor of a static
singleton
//This static singleton also creates the context. It also manages their
destruction
//later ...
sub->connect("inproc://killpub");
pub->connect("inproc://killsub");
Now my questions: for xpub and xsub do you do the following:
pub->setsockopt(ZMQ_SUBSCRIBE, "", 0);
at all? Or does the following handle it completely:
char *s = "xsubscriptionprefix";
s[0]='\x01';
sub->send(s);
where messages sent by pub that start with subscriptionprefix will be
forwarded to sub?
Also is there a need for unsubscription upon closure of sub?
char *s="\x00";
sub->send(s);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20141229/8c66bbb3/attachment.htm>
More information about the zeromq-dev
mailing list