server(Port,Password):- password<=Password, new_server(Port,Server), Server\=='$null', this_server<=Server, println(server_ready_on_port(Port)). % run:-server(7001,none),serve. serve:- this_server=>Server, password=>Password, repeat, ( new_service(Server,Service)-> bg(main_service_loop(Service,Password)), fail ; true ), !. main_service_loop(Service,Password):- service_finished<=no, repeat, ( (service_finished=>yes)->true ; answer_one_query(Service,Password)->fail ; true ), !, disconnect(Service).