Skip to content

Instantly share code, notes, and snippets.

@ahmedfgad
Created June 23, 2020 19:40
Show Gist options
  • Save ahmedfgad/53a7fc51ac3de14d7e65c3b248867463 to your computer and use it in GitHub Desktop.
Save ahmedfgad/53a7fc51ac3de14d7e65c3b248867463 to your computer and use it in GitHub Desktop.
connected = False
accept_timeout = 10
soc.settimeout(accept_timeout)
try:
connection, address = soc.accept()
print("Connected to a client: {client_info}.".format(client_info=address))
connected = True
except socket.timeout:
print("A socket.timeout exception occurred because the server did not receive any connection for {accept_timeout} seconds.".format(accept_timeout=accept_timeout))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment