Jul-04-2022, 07:35 PM
(This post was last modified: Jul-04-2022, 07:36 PM by wolfman5874.)
ahhhhh I figured it out. I took out the "if not data" statement and replaced it with "if c == file_size" and it breaks successfully without breaking the connection.
server:
server:
with open("node.msi", "rb") as file: c = 0 start_time = time.time() while c <= file_size: data = file.read(1024) conn.send(data) c = c + len(data) if c == file_size: end_time = time.time() print("send time: ", end_time - start_time) file.close() breakclient:
with open("./recv/" + "node.msi", "wb") as file: c = 0 start_time = time.time() while c <= int(file_size): data = client_socket.recv(1024) file.write(data) c = c + len(data) if c == int(file_size): file.close() end_time = time.time() print("download time: ", end_time - start_time) break