def main(): """The main function""" # Connection to IGS try: sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM) except: print ("ER: Unable to connect the server") return 0 try: sock.connect(('localhost', int(igsconfig.get('PORT')))) except: print ("ER: Unable to connect the server"); return 0 print ('What do you want to do ?') print ("\t1. Create a new super user") print ("\t2. Remove a super user") print ("\texit") # Selecting choice while 1: r = input ('> ') if r == '1' or r == '2' or r == 'exit' or r == 'quit': break else: print ('ER: Wrong choice') if r == '1': new_su() elif r == '2': remove_su() elif r == 'exit' or r == 'quit': sock.close() return 0 else: print ("ER: Wrong choice") sock.close() return 0
print ('Ready...') sock.listen(5) # Waiting for client connection # Clients dictionnary CLIENTS = {} while True: client, addr = sock.accept() # New object with that manage the client client_thread = Client(client) client_thread.start() # Save connection in the dictionnary thread_id = client_thread.getName() CLIENTS[thread_id] = client print ("Client %s is connected (%s:%s)" % (thread_id, addr[0], addr[1])) #client.send (b"connected") if __name__ == "__main__": # Start IGS HOST, PORT = igsconfig.get('HOST'), igsconfig.get('PORT') start_server(HOST,int(PORT))