tcpServer: Handle connection reset
This commit is contained in:
parent
0bfd7a70b2
commit
d1e4466fba
|
@ -22,12 +22,16 @@ while True:
|
|||
print(f'Switch Connected! IP: {client_address[0]} Port: {client_address[1]}')
|
||||
while True:
|
||||
data = connection.recv(1024)
|
||||
|
||||
if data:
|
||||
print(data.decode("utf-8"), end='', flush=True)
|
||||
else:
|
||||
print(f'Connection Terminated.')
|
||||
break
|
||||
|
||||
except ConnectionResetError:
|
||||
print("Connection reset")
|
||||
|
||||
finally:
|
||||
# Clean up the connection
|
||||
connection.close()
|
||||
connection.close()
|
||||
|
|
Loading…
Reference in New Issue