断开处理

This commit is contained in:
ranchuan
2024-10-08 18:46:04 +08:00
parent b36e74f798
commit 554191bc00
2 changed files with 6 additions and 2 deletions

View File

@@ -95,6 +95,7 @@ def remote_client_handler(tcp_remote:socket):
break
tcp_remote.close()
print("proxy close")
close_all()
if _local_server is not None:
_local_server.close()
@@ -128,7 +129,10 @@ def local_client_handler(tcp_server:socket,addr):
if(_remote_client is not None):
cmd={'device':'client','option':'disconnect','ip':addr[0],'port':addr[1]}
data=pc.encode(json.dumps(cmd).encode('utf-8'),b'default')
_remote_client.send(data)
try:
_remote_client.send(data)
except Exception as e:
print("remote close",str(e))
_local_client.remove(addr_info)

View File

@@ -131,7 +131,7 @@ def remote_client_handler(tcp_client_1:socket):
break
tcp_client_1.close()
print("proxy close.")
close_all()
def main():