This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Simple Client

By: a guest on Jan 18th, 2014  |  syntax: Python  |  size: 0.71 KB  |  views: 40  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/env python
  2.  
  3. """docstring"""
  4.  
  5. import socket
  6. import time
  7.  
  8. __author__ = 'Peter McKinney'
  9. __date__ = '14/01/14'
  10. __copyright__ = 'Copyright 2013, Peter McKinney'
  11. __license__ = "FreeBSD"
  12. __maintainer__ = 'Peter McKinney'
  13. __email__ = 'peter.mckinney21@gmail.com'
  14. __status_ = 'Prototype'
  15.  
  16. HOST = "SERVERS HOST"
  17. PORT = 7286             # The same port as used by the server
  18.  
  19.  
  20. while 1:
  21.     try:
  22.         s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  23.         s.connect((HOST, PORT))
  24.         s.send('[TIME]')
  25.         data = s.recv(1024)
  26.         s.close()
  27.         print 'Received', repr(data)
  28.     except Exception as e:
  29.         print 'Connection Error'
  30.         pass
  31.  
  32.     time.sleep(0.5)
clone this paste RAW Paste Data