A Persistent Uppercase Server Using TCP
import SocketServer
import netstring
class MyRequestHandler(SocketServer.BaseRequestHandler):
def handle(self):
print "From:", self.client_address
while 1:
rq = netstring.readns(self.request)
print rq
netstring.writens(self.request, rq.upper())
if rq.lower() == "end":
break
myServer = SocketServer.TCPServer(('', 8081),
MyRequestHandler)
myServer.handle_request()
Related examples in the same category