Skip to content

Instantly share code, notes, and snippets.

@BMU-Verlag
Created January 23, 2020 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BMU-Verlag/ffccfeceb619b7319fab850c6baf105c to your computer and use it in GitHub Desktop.
Save BMU-Verlag/ffccfeceb619b7319fab850c6baf105c to your computer and use it in GitHub Desktop.
for socket in read_sockets:
if socket == server_socket:
client_socket, client_address = server_socket.accept()
all_sockets.append(client_socket)
print(f'Established connection to {client_address[0]}:{client_address[1]}')
else:
message = receive(socket)
if not message:
print(f'{client_socket.getpeername()[0]}:{client_socket. getpeername() [1]} closed the connection')
sockets_list.remove(socket)
continue
broadcast(socket, message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment