[zeromq-dev] fire up new subscribers

Pieter Hintjens ph at imatix.com
Wed Aug 15 08:15:06 CEST 2012


On Tue, Aug 14, 2012 at 10:30 PM, Chuck Remes <lists at chuckremes.com> wrote:

> You are using undocumented socket types. Unless you feel like digging into the code and figuring this out yourself, I recommend you use socket types that have already been documented.

The XSUB and XPUB socket types are documented, in the 0MQ/3.2 reference manual:

ZMQ_XPUB - Same as ZMQ_PUB except that you can receive subscriptions
from the peers in form of incoming messages. Subscription message is a
byte 1 (for subscriptions) or byte 0 (for unsubscriptions) followed by
the subscription body.

ZMQ_XSUB - Same as ZMQ_SUB except that you subscribe by sending
subscription messages to the socket. Subscription message is a byte 1
(for subscriptions) or byte 0 (for unsubscriptions) followed by the
subscription body.

You cannot set a SUBSCRIBE option on an XSUB, only on a SUB socket,
which implements that by sending a message to the XPUB socket as
explained here above.

To use XPUB or XSUB you must be using 3.2. To solve the problem of
subscriber detection you can use XPUB, which means using 3.2. You can
connect a SUB to an XPUB, just fine.

-Pieter



More information about the zeromq-dev mailing list