SHARE
TWEET

Untitled

a guest Nov 16th, 2016 120 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import socket
  2. import sys
  3.  
  4. HOST, PORT = "localhost", 9999
  5. data = " ".join(sys.argv[1:])
  6.  
  7. # Create a socket (SOCK_STREAM means a TCP socket)
  8. with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
  9.     # Connect to server and send data
  10.     sock.connect((HOST, PORT))
  11.     sock.sendall(bytes(data + "\n", "utf-8"))
  12.  
  13.     # Receive data from the server and shut down
  14.     received = str(sock.recv(1024), "utf-8")
  15.  
  16. print("Sent:     {}".format(data))
  17. print("Received: {}".format(received))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top