Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #
  2. # python3
  3. # sudo apt-get install python3-pip
  4. # pip3 install pyzmq
  5. #
  6. # Hello World server in Python
  7. # Binds REP socket to tcp://*:5555
  8. # Expects b"Hello" from client, replies with b"World"
  9. #
  10.  
  11. import time
  12. import zmq
  13.  
  14. context = zmq.Context()
  15. socket = context.socket(zmq.REP)
  16. socket.bind("tcp://*:5555")
  17.  
  18. while True:
  19. # Wait for next request from client
  20. message = socket.recv()
  21. print("Received request: %s" % message)
  22.  
  23. # Do some 'work'
  24. time.sleep(1)
  25.  
  26. # Send reply back to client
  27. socket.send(b"World")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement