Created
April 5, 2016 13:53
-
-
Save estan/6aae102b3ae6b87413b199ef60461622 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import sleep | |
import zmq | |
context = zmq.Context() | |
socket = context.socket(zmq.PUB) | |
socket.bind("tcp://*:9001") | |
while True: | |
socket.send_json(('vidar', {'foo': 'bar'})) | |
sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zmq | |
context = zmq.Context() | |
socket = context.socket(zmq.SUB) | |
socket.connect('tcp://localhost:9001') | |
socket.subscribe = bytes() # Works. | |
#socket.subscribe = bytes('vidar', 'utf8') # Doesn't work :( | |
while True: | |
(topic, message) = socket.recv_json() | |
print('got {} on topic {}'.format(message, topic)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment