i32 CServer::main() { #ifdef ROBOTS_IN_SERVER return main_local(); #else return main_remote(); #endif }
int main(int argc, char **argv) { if (argc < 2) { show_help(argv[0]); exit(1); } if (strcmp(argv[1], "assemble") == 0) { return main_assemble(argc - 1, argv + 1); } else if (strcmp(argv[1], "local") == 0) { return main_local(argc - 1 , argv + 1); } else if (strcmp(argv[1], "iterate") == 0) { return main_iterate(argc - 1, argv + 1); } else if (strcmp(argv[1], "buildlib") == 0) { return main_build_lib(argc - 1, argv + 1); } else if (strcmp(argv[1], "dumpversion") == 0) { printf("%s\n", PACKAGE_VERSION); return 0; } else { show_help(argv[0]); exit(1); } return 0; }
int main(int argc, char **argv) { qi::Application app(argc, argv); std::string usage = "If no mode is specified, run client and server in same process\n"; po::options_description desc(std::string("Usage:\n ")+argv[0]+"\n" + usage); desc.add_options() ("help,h", "Print this help.") ("all", po::value<std::string>()->default_value("tcp://0.0.0.0:0"), "(default) Run all in the same process.") ("client,c", po::value<std::string>(), "Run as a client (tcp://xxx.xxx.xxx.xxx:xxxxx).") ("server,s", po::value<std::string>()->implicit_value("tcp://0.0.0.0:0"), "Run as a server.") ("gateway", po::value<std::string>(), "Run as a gateway.") ("local", "Run in local.") ("thread", po::value<int>()->default_value(1, "1"), "Number of thread to launch for clients") ("valgrind", "Set low loopcount and wait for valgrind.") ("gateway", "Run without gateway.") ("rstart", po::value<int>()->default_value(0, "0"), "rstart") ("rend", po::value<int>()->default_value(20, "20"), "rend") ("pipeline", po::value<int>()->default_value(1, "1"), "Max number of parallel calls to run") ("threadsafe", po::bool_switch()->default_value(false), "Declare threadsafe service") ("msdelay", po::value<int>()->default_value(0, "0"), "Delay in milliseconds to simulate long call") ; desc.add(qi::details::getPerfOptions()); po::variables_map vm; po::store(po::command_line_parser(argc, argv) .options(desc).run(), vm); po::notify(vm); if (vm.count("help")) { std::cout << desc << std::endl; return EXIT_SUCCESS; } if (vm.count("gateway")) noGateway = false; if (vm.count("valgrind")) { gLoopCount = 500; valgrind = true; } if (vm.count("client") + vm.count("server") + !vm["all"].defaulted() + vm.count("gateway") + vm.count("local") > 1) { std::cerr << desc << std::endl << "You must put at most one option between [all|client|server|gateway|local]" << std::endl; return EXIT_FAILURE; } if (!vm["thread"].defaulted() && (vm.count("server") != 0 || vm.count("gateway") != 0)) { std::cerr << "[thread] is useless with [server] or [gateway]" << std::endl; } rstart = vm["rstart"].as<int>(); rend = vm["rend"].as<int>(); pipeline = vm["pipeline"].as<int>(); threadsafe = vm["threadsafe"].as<bool>(); msDelay = vm["msdelay"].as<int>(); out = new qi::DataPerfSuite("qimessaging", "transport", qi::DataPerfSuite::OutputData_Period, vm["output"].as<std::string>()); if (vm.count("client")) { serverUrl = qi::Url(vm["client"].as<std::string>()); int threadc = vm["thread"].as<int>(); start_client(threadc); } else if (vm.count("server")) { serverUrl = vm["server"].as<std::string>(); return main_server(); } else if (vm.count("gateway")) { serverUrl = vm["gateway"].as<std::string>(); return main_gateway(serverUrl); } else if (vm.count("local")) { return main_local(); } else { //start the server int threadc = vm["thread"].as<int>(); serverUrl = vm["all"].as<std::string>(); allInOne = true; boost::thread threadServer1(boost::bind(&main_server)); do { qi::os::msleep(500); // give it time to listen } while (!serverReady); // be nice for valgrind if (!noGateway) boost::thread threadServer2(boost::bind(&main_gateway, serverUrl)); qi::os::sleep(1); start_client(threadc); } delete out; return EXIT_SUCCESS; }