Catch exception if host is not found

This commit is contained in:
me-no-dev 2017-03-11 09:07:25 +02:00
parent fa1716e73e
commit bc7aa60a30

View File

@ -98,7 +98,14 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
inv_trys += 1 inv_trys += 1
sock2 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock2 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
remote_address = (remoteAddr, int(remotePort)) remote_address = (remoteAddr, int(remotePort))
try:
sent = sock2.sendto(message.encode(), remote_address) sent = sock2.sendto(message.encode(), remote_address)
except:
sys.stderr.write('failed\n')
sys.stderr.flush()
sock2.close()
logging.error('Host %s Not Found', remoteAddr)
return 1
sock2.settimeout(1) sock2.settimeout(1)
try: try:
data = sock2.recv(37).decode() data = sock2.recv(37).decode()