import SocketServerimport netstringimport sysclass MyRequestHandler(SocketServer.BaseRequestHandler): def handle(self): global Done request, socket = self.request rq = netstring.decode(request) print "From:", self.client_address, ":", rq sys.stdout.flush() result = netstring.encode(rq.upper()) if result == "END": Done = 1 return socket.sendto(result, self.client_address)myServer = SocketServer.UDPServer(('', 8081),MyRequestHandler)Done = Nonewhile not Done: myServer.handle_request()
Name (required)
email (will not be published) (required)
Website