Skip to content

Instantly share code, notes, and snippets.

@yhilpisch
Created September 19, 2016 16:30
Show Gist options
  • Save yhilpisch/1297fa26eb71cfdc845bc0a1b58c34be to your computer and use it in GitHub Desktop.
Save yhilpisch/1297fa26eb71cfdc845bc0a1b58c34be to your computer and use it in GitHub Desktop.
ZeroMQ Server and Client
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)
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