本文整理汇总了C++中server::stop方法的典型用法代码示例。如果您正苦于以下问题:C++ server::stop方法的具体用法?C++ server::stop怎么用?C++ server::stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类server
的用法示例。
在下文中一共展示了server::stop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shutDown
void shutDown() {
cout << "System shutting down." << endl;
websocket_server.close(currentState.client, 0, "shutdown");
websocket_server.stop();
gpioTerminate();
std::exit(EXIT_SUCCESS);
//system("shutdown -P now");
return;
}
示例2: main
int main(int argc, char **argv) {
/* Program start */
/*
*
*
*/
int i;
int port = 5000;
char *bind = (char *)"0.0.0.0";
bool daemon = false;
/* Help info */
for(i=0;i<argc;i++) {
if(strcmp(argv[i],"-h")==0||strcmp(argv[i],"--help")==0) {
out("Usage: cframes [options]\n");
out("\t-p, --port PORT\tBind server socket to specified PORT\n");
out("\t\t\tDefault: 5000\n");
out("\t-b, --bind IP\tBind server to specified IP\n");
out("\t\t\tDefault: 0.0.0.0\n");
out("\t-d, --daemon\tForks server process\n");
out("\t-h, --help\tDisplay this help and exit\n");
out("\t-v, --version\tDisplay version information and exit\n");
return 0;
}
}
/* Version info */
for(i=0;i<argc;i++) {
if(strcmp(argv[i],"-v")==0||strcmp(argv[i],"--version")==0) {
out("cframes 1.0.1\n");
return 0;
}
}
/* Program arguments */
for(i=0;i<argc;i++) {
if(strcmp(argv[i],"-p")==0||strcmp(argv[i],"--port")==0) {
port = (int)argv[i+1];
}
if(strcmp(argv[i],"-b")==0||strcmp(argv[i],"--bind")==0) {
bind = (char *)argv[i+1];
}
if(strcmp(argv[i],"-d")==0||strcmp(argv[i],"--daemon")==0) {
daemon = true;
}
}
/* Start the server */
out("Starting cframes server...........");
s.start(port);
out("OK\n");
out("Listening on http://");
out(bind);out(":");out("5000");out("\n\n");
/* Single-threaded forever loop to handle requests -- NOTE: eventually will have a daemon option -d */
for(i=0;i<50;i++) { www(); }
/* Stop the server */
s.stop();
return 0;
}