Skip to content

Commit 4a52467

Browse files
authored
Fix send_file.py
Add a check for conn.recv(1024) to prevent the thread from blocking.
1 parent e59d819 commit 4a52467

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

file_transfer/send_file.py

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ def send_file(filename: str = "mytext.txt", testing: bool = False) -> None:
1313
conn, addr = sock.accept() # Establish connection with client.
1414
print(f"Got connection from {addr}")
1515
data = conn.recv(1024)
16+
if not data:
17+
break #IF NOT data received,the Client has closed the Connection.
1618
print(f"Server received: {data = }")
1719

1820
with open(filename, "rb") as in_file:

0 commit comments

Comments
 (0)