From 06f0e9d7f9e7a3bc88878699466564b146daa6c2 Mon Sep 17 00:00:00 2001 From: saradiya <56483022+saradiya@users.noreply.github.com> Date: Sat, 12 Oct 2019 21:34:02 +0530 Subject: [PATCH] try except code update --- server_code.py | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/server_code.py b/server_code.py index 13a8896..04b9568 100755 --- a/server_code.py +++ b/server_code.py @@ -86,25 +86,13 @@ def broadcast(message, connection): def remove(connection): if connection in list_of_clients: list_of_clients.remove(connection) +try: + host_ip = socket.gethostbyname('www.google.com') +except socket.gaierror: -while True: - - """Accepts a connection request and stores two parameters, - conn which is a socket object for that user, and addr - which contains the IP address of the client that just - connected""" - conn, addr = server.accept() - - """Maintains a list of clients for ease of broadcasting - a message to all available people in the chatroom""" - list_of_clients.append(conn) - - # prints the address of the user that just connected - print(addr[0] + " connected") - - # creates and individual thread for every user - # that connects - start_new_thread(clientthread,(conn,addr)) + # this means could not resolve the host + print "there was an error resolving the host" + sys.exit() conn.close() server.close()