def sale_new_client(self, name, phone, address): # se crea un nuevo cliente client = Client(name, phone, address, 0) print("Venta a nuevo cliente {}, phone {}, address {}".format(client.name, client.phone, client.address)) # se guarda su informacion self.update_client(client)
def verifyClient(conn, client): signup=conn.recv(1024).decode('utf-8').strip() username=conn.recv(1024).decode('utf-8').strip() password=conn.recv(1024).decode('utf-8').strip() log.debug("signup: " + signup) log.debug("username: "******"password: "******"0010": return (username, s) else: s = verify(username, password, client) if s != "0010": return (username, s) return username, "0010"
def check_conn(): while True: sleep(15) Client.kill_inactive()
def debugging(): client = Client() pdb.set_trace()
def debugging(): '''opens pdb interface for debugging purpose''' client = Client() pdb.set_trace()
check_backlog(client) startchat(client, "") def debugging(): client = Client() pdb.set_trace() def check_conn(): while True: sleep(15) Client.kill_inactive() if __name__ == '__main__': '''main function''' if len(argv) != 3: print(colored("Correct Usage: script host port", 'red')) exit() host, port = argv[1], int(argv[2]) start_new_thread(debugging, ()) start_new_thread(check_conn, ()) for connaddr in client_gen(host, port): client = Client(connaddr[0], connaddr[1]) print("One connection was received: ", client.addr) t = threading.Thread(target=client_thread, args=(client, )) t.start()
if __name__ == "__main__": c = None s = None try: client_port = 9001 # this is the other server's port server_port = 9001 # this is the port that you are hosting ## Server Setup s = Server("", server_port) s.bindSetup() x = Thread(target=s.serverLoop) x.start() ## Client Setup c = Client("", client_port) c.connect() y = Thread(target=c.clientLoop) y.start() x.join() y.join() except KeyboardInterrupt: print("Pressed CTL+C") finally: if s: s.close() if c: c.close()