luisfmelo
12/5/2016 - 8:00 PM

TCP Client Python

import socket, time

port = 9999
host = 'localhost'

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((host, port)) 
count = 0
while 1:
   msg = raw_input("Please enter something: ")
   print client.send(msg)
   if msg == 'exit':
      break
   time.sleep(0.1)

print "Good bye!"