import socket # Create a socket for the server server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Bind the socket to a local address server_socket.bind(("0.0.0.0", 8000)) # Listen for incoming connections server_socket.listen() # Create a list to store the clients clients = [] while True: # Accept incoming connections client_socket, client_address = server_socket.accept() # Add the client to the list of clients clients.append(client_socket) # Receive data from the client data = client_socket.recv(1024) # Iterate over the clients and send the data to each of them for client in clients: client.sendall(data)