[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);
  _xsub = new zmq::socket_t(_context, ZMQ_XSUB);

//These sockets are created and bound in the constructor of a static
//This static singleton also creates the context. It also manages their
//later ...


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";

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";
-------------- 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