Created
September 19, 2016 16:30
-
-
Save yhilpisch/1297fa26eb71cfdc845bc0a1b58c34be to your computer and use it in GitHub Desktop.
ZeroMQ Server and Client
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://0.0.0.0:8888') | |
socket.setsockopt_string(zmq.SUBSCRIBE, u'value') | |
while True: | |
data = socket.recv_string() | |
print(data) |
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 | |
import random | |
import time | |
context = zmq.Context() | |
socket = context.socket(zmq.PUB) | |
socket.bind('tcp://0.0.0.0:8888') | |
value = 100. | |
while True: | |
value += random.gauss(0, 1) | |
socket.send_string('value %s' % value) | |
print('value %s' % value) | |
time.sleep(random.random()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment