Skip to content

Instantly share code, notes, and snippets.

@g19fanatic
Created October 23, 2012 17:10
Show Gist options
  • Save g19fanatic/3940128 to your computer and use it in GitHub Desktop.
Save g19fanatic/3940128 to your computer and use it in GitHub Desktop.
Example Publisher
import zmq
con = zmq.Context()
sock = con.socket(zmq.PUB)
sock.bind("tcp://localhost:5000")
i = 0
while True:
i = i + 1
msg = "%s %s" % (i, i*i+i-2*i)
sock.send(msg)
if i > 1000:
i = 0
import zmq
con = zmq.Context()
sock = con.socket(zmq.SUB)
sock.setsockopt(zmq.SUBSCRIBE, "5")
sock.connect("tcp://localhost:5000")
while True:
print sock.recv()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment