Posted By


JordanRowles on 04/12/14

Tagged


Statistics


Viewed 116 times
Favorited by 0 user(s)

SocketServer_Client.py


/ Published in: Python
Save to your folder(s)

Client code for sending information to the logging server.


Copy this code and paste it in your HTML
  1. # SocketServer_Client.py
  2. # Version: 1.0
  3. # Use: Internal Application (Work)
  4. # Purpose: Client-side code for sending information to the server.
  5. # Copyright (C)2014 Jordan Rowles
  6. # GNU General Public License Version 3 or Later
  7.  
  8. import socket
  9. import sys
  10.  
  11. HOST, PORT = 'localhost', 9999
  12. DATA = " ".join(sys.argv[1:])
  13. sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  14.  
  15. try:
  16. sock.connect((HOST, PORT))
  17. sock.sendall(DATA+"\n")
  18. received = sock.recv(1024)
  19. finally:
  20. sock.close()
  21.  
  22. print " Sent: {}".format(DATA)
  23. print "Received: {}".format(received)

URL: SocketServer-Client

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.