Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions server_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()