socket server 示例
#服务端程序 import socketserver class TcpHandler(socketserver.BaseRequestHandler): def handle(self): while True: try: self.data = self.request.recv(1024).strip() print(self.client_address[0]) print(self.data) self.request.send(self.data.upper()) except ConnectionResetError as e: print("连接断开") break if __name__ =="__main__": HOST,PORT ="localhost",9009 server = socketserver.ThreadingTCPServer((HOST,PORT),TcpHandler) server.serve_forever()
FTP 代码见 github https://github.com/liruixinnote/learn/tree/master/soft_ware