better socket connection error handling
This commit is contained in:
+2
-3
@@ -28,15 +28,14 @@ def main():
|
||||
|
||||
# open TCP connection to server
|
||||
with socket() as sock:
|
||||
sock.settimeout(args.socket_timeout or 30)
|
||||
try:
|
||||
sock.connect((RCON_ADDRESS, RCON_PORT))
|
||||
except:
|
||||
except OSError: # OSError is the parent of a few different errors we want to gracefully catch here
|
||||
print(f"{GRY} Connection to server failed. {RST}")
|
||||
print(f"{GRY} Please check the server hostname and port, then try again. {RST}")
|
||||
exit(1)
|
||||
|
||||
sock.settimeout(args.socket_timeout or 30)
|
||||
|
||||
# login attempts
|
||||
login_success = login(sock, RCON_PASSWORD)
|
||||
while (not login_success):
|
||||
|
||||
Reference in New Issue
Block a user