python为socket handler创建一个处理类及调用方法
import SocketServer port = 8000 class myRequestHandler(SocketServer.StreamRequestHandler): def handle(self): print "connection from ", self.client_address self.wfile.write("data") srvsocket = SocketServer.TCPServer(("", port), myRequestHandler) print "The socket is listening to port", port srvsocket.serve_forever()