Created
June 5, 2020 03:39
-
-
Save timothymugayi/1f73471174062d4b2055645f48d3d13e to your computer and use it in GitHub Desktop.
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
# 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