Skip to content

Instantly share code, notes, and snippets.

@bwhite
Created September 21, 2012 23:07
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save bwhite/3764428 to your computer and use it in GitHub Desktop.
Save bwhite/3764428 to your computer and use it in GitHub Desktop.
ZMQ Req/Rep Example
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"
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')
@kylemcdonald
Copy link

In Python 3, this should use send_string or it should send b'0' and 'b'1'`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment