while True: print("Waiting for Clients to connect") try: (cs, client_ip_port) = ls.accept() print("A client has connected to the server!") count_connections += 1 client_addres_list.append((cs, client_ip_port)) print("CONNECTION " + str(count_connections) + ". Client IP, PORT: " + str(client_ip_port)) except KeyboardInterrupt: print("Server stopped by the user") ls.close() exit() msg_raw = cs.recv(2048) msg = msg_raw.decode() formatted_msg = Server_utils.format_command(msg) formatted_msg = formatted_msg.split(" ") if len(formatted_msg) == 1: command = formatted_msg[0] else: command = formatted_msg[0] + '"' argument = '"' + formatted_msg[1] if command == '"PING"': Server_utils.ping(cs) elif command == '"GET"': Server_utils.get(list_sequences, cs, argument) elif command == '"INFO"': Server_utils.info(argument, cs)
while True: print("Waiting for Clients to connect") try: (cs, client_ip_port) = ls.accept() client_address_list.append(client_ip_port) count_connections += 1 print('Connection: ' + str(count_connections) + '. Client ip, port: ' + str(client_ip_port)) except KeyboardInterrupt: print("Server stopped by the user") ls.close() exit() msg_raw = cs.recv(2048) msg = msg_raw.decode() formatted_msg = su.format_command(msg) #print(formatted_msg) formatted_msg = formatted_msg.split(' ') if len(formatted_msg) == 1: command = formatted_msg[0] else: command = formatted_msg[0] argument = formatted_msg[1] if command == 'PING': su.ping(cs) elif command == 'GET': su.get(cs, list_sequences, argument) elif command == 'INFO': su.info(cs, argument)