On Aug 14, 2012, at 8:10 AM, andrea crotti wrote:

> 2012/8/14 Pieter Hintjens <[email protected]>:
>> On Tue, Aug 14, 2012 at 9:00 PM, andrea crotti
>> <[email protected]> wrote:
>> 
>>>> Maybe an example would be nice to have in the guide or in the examples
>>>> directory, what do you think?
>> 
>> Yes, when we update the Guide for 3.x...
>> 
>>> This for example doesn't work, because the setsockopt is not compatible:
>>> Traceback (most recent call last):
>>>  File "xsub.py", line 21, in <module>
>>>    sock.setsockopt(zmq.SUBSCRIBE, '')
>> 
>> Set the subscription on a SUB socket, not an XSUB.
>> 
>> -Pieter
> 
> 
> I don't understand what you mean exactly, and changing XSUB to SUB
> still doesn't work...

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.

In this example, you cannot call zmq_setsockopt() on a XSUB socket and pass the 
ZMQ_SUBSCRIBE flag. It is not supported. To set the subscription using XSUB 
directly, you would need to generate and send messages using the proper 
formatting for an upstream PUB socket to understand. You could figure this out 
by looking at how a SUB socket does it since that socket type is built on top 
of XSUB.

Shorter answer: you will need to read the code to figure this out. Alternately, 
wait for updated documentation that could be months away.

> And where should I use XSUB then if the subscriber should always be SUB?
> 
> But a more important question, is XSUB supposed to work fine on 2.2
> too since that's what I have to use now for production?

Andrea, this was answered about a week ago in this same thread. You need 3.2 to 
use XSUB.

cr

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to