[zeromq-dev] Problem with setsockopt_unicode

Maxa Jean Aimee maxajeanaimee at yahoo.fr
Mon Jan 7 09:32:30 CET 2013

Hi everyone, 
I would like to solve some problems about publish/subscribe with zeromq new version.
This is a piece of my code 

import zmq
from random import choice
import msgpack
context = zmq.Context()
socket = context.socket(zmq.PUB)
countries = ['netherlands','brazil','germany','portugal']
events = ['yellow card', 'red card', 'goal', 'corner', 'foul']
while True:
    msg = choice( countries ) +" "+ choice( events )
    print ("->",msg)
    msg =msgpack.packb(msg)
    socket.send( msg ) 


import zmq
context = zmq.Context()
socket = context.socket(zmq.SUB)
socket.setsockopt_unicode(zmq.SUBSCRIBE, "netherlands")
socket.setsockopt_unicode(zmq.SUBSCRIBE, "germany")
while True:

The problem is when I launch the sub.py to see if i receive my subscription correctly, it turned out that i got nothing.
There is nothing comes out to the ouput.

It should print the result of the subscription, how setsockopt_unicode really works ?

It works when i did use the old version of zmq.

It's very confusing !
Anyhelp would be appreciated 

Jean Aimé MAXA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130107/02fa7fa3/attachment.htm>

More information about the zeromq-dev mailing list