mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-04-18 19:57:35 +00:00
Fix send_file.py
Add a check for conn.recv(1024) to prevent the thread from blocking.
This commit is contained in:
parent
e59d819d09
commit
4a5246786a
@ -13,6 +13,8 @@ def send_file(filename: str = "mytext.txt", testing: bool = False) -> None:
|
|||||||
conn, addr = sock.accept() # Establish connection with client.
|
conn, addr = sock.accept() # Establish connection with client.
|
||||||
print(f"Got connection from {addr}")
|
print(f"Got connection from {addr}")
|
||||||
data = conn.recv(1024)
|
data = conn.recv(1024)
|
||||||
|
if not data:
|
||||||
|
break #IF NOT data received,the Client has closed the Connection.
|
||||||
print(f"Server received: {data = }")
|
print(f"Server received: {data = }")
|
||||||
|
|
||||||
with open(filename, "rb") as in_file:
|
with open(filename, "rb") as in_file:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user