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()