Skip to content

Commit bc7aa60

Browse files
committed
Catch exception if host is not found
1 parent fa1716e commit bc7aa60

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tools/espota.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,14 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
9898
inv_trys += 1
9999
sock2 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
100100
remote_address = (remoteAddr, int(remotePort))
101-
sent = sock2.sendto(message.encode(), remote_address)
101+
try:
102+
sent = sock2.sendto(message.encode(), remote_address)
103+
except:
104+
sys.stderr.write('failed\n')
105+
sys.stderr.flush()
106+
sock2.close()
107+
logging.error('Host %s Not Found', remoteAddr)
108+
return 1
102109
sock2.settimeout(1)
103110
try:
104111
data = sock2.recv(37).decode()

0 commit comments

Comments
 (0)