A Multithreaded Uppercase Server : TCP : Network PYTHON examples


PYTHON examples » Network » TCP »

 

A Multithreaded Uppercase Server


 
import SocketServer
import netstring
import sys
import string

class MyRequestHandler(SocketServer.BaseRequestHandler):
    def handle(self):
        print "Connected:", self.client_address
        while 1:
            rq = netstring.readns(self.request)
            print "From:", self.client_address, rq
            sys.stdout.flush()
            if rq == "":
                break
            netstring.writens(self.request, string.upper(rq))

myServer = SocketServer.ThreadingTCPServer(('', 8081),
                MyRequestHandler)
myServer.serve_forever()

   
  



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Network
» TCP