Guest User

server.py

a guest
Jul 7th, 2013
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import random
  4. import time
  5.  
  6. import zmq
  7.  
  8. def main():
  9.     host = "tcp://127.0.0.1:5554"
  10.  
  11.     ctx = zmq.Context()
  12.     sock = ctx.socket(zmq.PAIR)
  13.     sock.bind(host)
  14.  
  15.     client_id = random.randint(0, 100)
  16.     try:
  17.         while True:
  18.             sock.send("Server message to client3")
  19.             msg = sock.recv()
  20.             print msg
  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