利用tcp协议实现大文件传输(socket)
server.pyimport socketimport jsonimport structsk = socket.socket()sk.bind(('127.0.0.1', 2000))sk.listen()conn, addr = sk.accept()msg_len = conn.recv(4)dic_len = struct.unpack("i", msg_len)[0] # 防止粘包msg = conn.recv(dic_len).decode("utf-8")ms
原创
2020-07-26 21:04:28 ·
1740 阅读 ·
0 评论