Advertisement
Guest User

client.py

a guest
Jan 8th, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2.  
  3. import socket
  4. import sys
  5. import json
  6.  
  7. def loop(connection):
  8.     while True:
  9.         data = json.loads(connection.recv(1024))
  10.         if data != 'exit':
  11.             print data
  12.         else:
  13.             print 'Quitting.'
  14.             break
  15.            
  16. # set IP and port
  17. host = '127.0.0.1'
  18. port = 9006
  19.  
  20. connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  21. connection.connect((host, port))
  22.  
  23. loop(connection)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement