Guest User

client.py

a guest
Jul 7th, 2013
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import time
  4.  
  5. import zmq
  6.  
  7. def main():
  8.     host = "tcp://127.0.0.1:5554"
  9.  
  10.     ctx = zmq.Context()
  11.     sock = ctx.socket(zmq.PAIR)
  12.     sock.connect(host)
  13.  
  14.     try:
  15.         sock.send("hello")
  16.         while True:
  17.             msg = sock.recv()
  18.             print msg
  19.             sock.send("client message to server1")
  20.             sock.send("client message to server2")
  21.             time.sleep(1)
  22.     except:
  23.         pass
  24.     finally:
  25.         sock.close()
  26.         ctx.term()
  27.  
  28. if __name__ == "__main__":
  29.     main()
Advertisement
Add Comment
Please, Sign In to add comment