Skip to content

Instantly share code, notes, and snippets.

@mehdisadeghi
Created January 13, 2015 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mehdisadeghi/252895d8264cf36c5743 to your computer and use it in GitHub Desktop.
Save mehdisadeghi/252895d8264cf36c5743 to your computer and use it in GitHub Desktop.
#
# Request-reply client in Python
# Connects REQ socket to tcp://localhost:5559
# Sends "Hello" to server, expects "World" back
#
import zmq
import sys
# Prepare our context and sockets
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect("tcp://localhost:40002")
# Get request
socket.send(b"get:", zmq.SNDMORE)
socket.send(b"the key")
print socket.recv()
# and for set
# Set request
#socket.send(b"set:", zmq.SNDMORE)
#socket.send(b"the key", zmq.SNDMORE)
#socket.send(value)
#print socket.recv()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment