[zeromq-dev] XSUB/XPUB proper usage

Pieter Hintjens ph at imatix.com
Tue Dec 30 06:24:52 CET 2014


There is nothing in the proxy code that would reject a XPUB or XSUB socket.

On Mon, Dec 29, 2014 at 11:50 PM, Kenneth Adam Miller
<kennethadammiller at gmail.com> wrote:
>
>
> On Mon, Dec 29, 2014 at 3:23 PM, Pieter Hintjens <ph at imatix.com> wrote:
>>
>> Either XSUB or SUB can connect to XPUB. With XSUB you have to send the
>> subscribe / unsubscribe messages yourself. With SUB they're sent by
>> the socket. In either case the XPUB will detect a dead (X)SUB peer and
>> generate ubsub messages up to the API.
>
>
> Thank you!
>
> Now I'm having issues with socket operation on non-socket exceptions...
>   _xpub = new zmq::socket_t(_context, ZMQ_XPUB);
>   _xpub->bind("inproc://killpub");
>   _xsub = new zmq::socket_t(_context, ZMQ_XSUB);
>   _xsub->bind("inproc://killsub");
>   zmq::proxy(_xsub, _xpub, NULL);  //throws here
>>
>>
>> On Mon, Dec 29, 2014 at 5:08 PM, Kenneth Adam Miller
>> <kennethadammiller at gmail.com> wrote:
>> >
>> > On Mon, Dec 29, 2014 at 11:03 AM, Pieter Hintjens <ph at imatix.com> wrote:
>> >>
>> >> On Mon, Dec 29, 2014 at 4:51 PM, Kenneth Adam Miller
>> >> <kennethadammiller at gmail.com> wrote:
>> >>
>> >> > Now my questions: for xpub and xsub do you do the following:
>> >> >   pub->setsockopt(ZMQ_SUBSCRIBE, "", 0);
>> >>
>> >> No, this works only on SUB sockets.
>> >>
>> > I meant sub->setsockopt... but now that makes me think- don't I use
>> > ZMQ_SUB
>> > to connect to ZMQ_XPUB?
>> >
>> >>
>> >> > at all? Or does the following handle it completely:
>> >> >   char *s = "xsubscriptionprefix";
>> >> >   s[0]='\x01';
>> >> >   sub->send(s);
>> >>
>> >> Yes.
>> >>
>> >> > Also is there a need for unsubscription upon closure of sub?
>> >> > char *s="\x00";
>> >> > sub->send(s);
>> >>
>> >> Not needed at the SUB side at all; it's handled by the PUB socket. (I
>> >> think, from memory.)
>> >>
>> >> -Pieter
>> >> _______________________________________________
>> >> zeromq-dev mailing list
>> >> zeromq-dev at lists.zeromq.org
>> >> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>> >
>> >
>> >
>> > _______________________________________________
>> > zeromq-dev mailing list
>> > zeromq-dev at lists.zeromq.org
>> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>> >
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>



More information about the zeromq-dev mailing list