An Uppercase Client Using TCP : TCP « Network « Python






An Uppercase Client Using TCP

 
import socket
import netstring

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.1', 8081))
while 1:
    arg = raw_input("Send: ")
    if not arg:
        netstring.writens(s, "end")
        break
    netstring.writens(s, arg)
    ret = netstring.readns(s)
    print "Returned:", ret
s.close()

   
  








Related examples in the same category

1.A Simple TCP Socket Client: Echo client program
2.A Simple TCP Socket Server: Echo server program
3.A Multithreaded Uppercase Server
4.A Persistent Uppercase Server Using TCP