Skip to content

Instantly share code, notes, and snippets.

@timothymugayi
Created June 5, 2020 03:39
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 timothymugayi/1f73471174062d4b2055645f48d3d13e to your computer and use it in GitHub Desktop.
Save timothymugayi/1f73471174062d4b2055645f48d3d13e to your computer and use it in GitHub Desktop.
# ZeroMQ response server in Python
# Binds REP socket to tcp://*:5555
# Expects b"string" from client, replies with b"Ok"
import time
import zmq
context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://*:5555")
while True:
# Wait for next request from client
message = socket.recv()
print("Received request: %s" % message)
# Do some 'work'
time.sleep(1)
# Send reply back to client
socket.send(b"Ok")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment