Created
October 23, 2012 17:10
-
-
Save g19fanatic/3940128 to your computer and use it in GitHub Desktop.
Example Publisher
This file contains hidden or 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 | |
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 |
This file contains hidden or 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 | |
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