import socketserver #实现并发的多线程
class MyServer(socketserver.BaseRequestHandler): #必须继承这个类
def handle(self): #必须实现这个方法
self.request.recv(1024) #self.request 相当于拿到的是一个连接
self.request.send()
if __name__ == '__main__':
server = socketserver.ThreadingTCPServer(('127.0.0.1',8090) ,MyServer) #socketserver.ThreadingTCPServer是一个类名。第二个参数是自己实现的类。
server.serve_forever()