Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # python3
- # sudo apt-get install python3-pip
- # pip3 install pyzmq
- #
- # Hello World server in Python
- # Binds REP socket to tcp://*:5555
- # Expects b"Hello" from client, replies with b"World"
- #
- 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"World")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement