[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
pub.py
import zmq
from random import choice
import msgpack
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.bind("tcp://127.0.0.1:5000")
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 )
sub.py
import zmq
context = zmq.Context()
socket = context.socket(zmq.SUB)
socket.connect("tcp://127.0.0.1:5000")
socket.setsockopt_unicode(zmq.SUBSCRIBE, "netherlands")
socket.setsockopt_unicode(zmq.SUBSCRIBE, "germany")
while True:
print(socket.recv())
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