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
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev