void CommonTestsSuite::test_setFdOptions() { InitNetworking(); int32_t fd = socket(AF_INET, SOCK_STREAM, 0); TS_ASSERT(fd > 0); TS_ASSERT(setFdNoSIGPIPE(fd)); TS_ASSERT(setFdNonBlock(fd)); TS_ASSERT(setFdNoNagle(fd)); TS_ASSERT(setFdKeepAlive(fd)); TS_ASSERT(setFdReuseAddress(fd)); CLOSE_SOCKET(fd); fd = -1; fd = socket(AF_INET, SOCK_STREAM, 0); TS_ASSERT(fd > 0); TS_ASSERT(setFdOptions(fd)); CLOSE_SOCKET(fd); }
int main(int argc, const char **argv) { SRAND(); InitNetworking(); //1. Pick up the startup parameters and hold them inside the running status if (argc < 2) { fprintf(stdout, "Invalid command line. Use --help\n"); return -1; } if (!Variant::DeserializeFromCmdLineArgs(argc, argv, gRs.commandLine)) { PrintHelp(); return -1; } string configFile = argv[argc - 1]; if (configFile.find("--") == 0) configFile = ""; NormalizeCommandLine(configFile); if ((bool)gRs.commandLine["arguments"]["--help"]) { PrintHelp(); return 0; } if ((bool)gRs.commandLine["arguments"]["--version"]) { PrintVersion(); return 0; } do { //2. Reset the run flag gRs.run = false; //3. Initialize the running status if (Initialize()) { Run(); } else { gRs.run = false; } //5. Cleanup Cleanup(); } while (gRs.run); //6. We are done return 0; }