1.导入socketserver,ThreadingTCPServer支持多client连接
import socketserver
class Mysocket(socketserver.BaseRequestHandler):
def handle(self):
while True:
try:
pass
except ConnectionResetError as e:
print(e)
if __name__=="__main__":
Host,port=‘localhost‘,8989
server=socketserver.ThreadingTCPServer((Host, port), Mysocket)
server.serve_forever()
原文地址:http://blog.51cto.com/13803166/2133041
时间: 2025-01-04 16:42:26