Guest User

Untitled

a guest
Jun 20th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #
  2. # Hello World client in Python
  3. # Connects REQ socket to tcp://localhost:5555
  4. # Sends "Hello" to server, expects "World" back
  5. #
  6.  
  7. import zmq
  8.  
  9. context = zmq.Context()
  10.  
  11. # Socket to talk to server
  12. print("Connecting to hello world server…")
  13. socket = context.socket(zmq.REQ)
  14. socket.connect("tcp://localhost:5555")
  15.  
  16. # Do 10 requests, waiting each time for a response
  17. for request in range(10):
  18. print("Sending request %s …" % request)
  19. socket.send(b"Hello")
  20.  
  21. # Get the reply.
  22. message = socket.recv()
  23. print("Received reply %s [ %s ]" % (request, message))
Add Comment
Please, Sign In to add comment