Posted By

JordanRowles on 04/12/14


Tagged

data socket server SocketServer


Versions (?)

SocketServer_Client.py


 / Published in: Python
 

URL: SocketServer-Client

Client code for sending information to the logging server.

  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)

Report this snippet  

You need to login to post a comment.