Created
September 21, 2012 23:07
-
-
Save bwhite/3764428 to your computer and use it in GitHub Desktop.
ZMQ Req/Rep Example
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 # Client | |
sock = zmq.Context().socket(zmq.REQ) | |
sock.connect("tcp://127.0.0.1:10000") | |
sock.send('0') | |
print(sock.recv()) # Prints "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 # Server | |
sock = zmq.Context().socket(zmq.REP) | |
sock.bind("tcp://127.0.0.1:10000") | |
print(sock.recv()) # Prints "0" | |
sock.send('1') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Python 3, this should use
send_string
or it should sendb'0'
and 'b'1'`