diff --git a/src/main.py b/src/main.py index 31755f3..98030f2 100644 --- a/src/main.py +++ b/src/main.py @@ -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):