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