• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ shutdown_server函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中shutdown_server函数的典型用法代码示例。如果您正苦于以下问题:C++ shutdown_server函数的具体用法?C++ shutdown_server怎么用?C++ shutdown_server使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了shutdown_server函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: end_test

static void end_test(grpc_end2end_test_fixture *f) {
  shutdown_server(f);
  shutdown_client(f);

  grpc_completion_queue_shutdown(f->cq);
  drain_cq(f->cq);
  grpc_completion_queue_destroy(f->cq);
}
开发者ID:WeiZhang555,项目名称:grpc,代码行数:8,代码来源:server_finishes_request.c


示例2: end_test

static void end_test(grpc_end2end_test_fixture *f) {
  shutdown_server(f);
  shutdown_client(f);

  grpc_completion_queue_shutdown(f->cq);
  drain_cq(f->cq);
  grpc_completion_queue_destroy(f->cq);
  /* Note: shutdown_cq is not used in this test */
  grpc_completion_queue_destroy(f->shutdown_cq);
}
开发者ID:makdharma,项目名称:grpc,代码行数:10,代码来源:graceful_server_shutdown.c


示例3: console_shutdown

static void console_shutdown(connection_type* ct, char *when)
{
	int min = 0;
	//if (!my_stricmp(when, "NOW")) min = 0;
	//else if (IS_VALID_NUMBER(when)) min = when

	/* Now */
	if (min == 0)
	{
		/* Tell */
		cq_printf(&ct->wbuf, "%T", "Server shutdown\n");

		/* Shutdown */
		shutdown_server();
	} 
	else
	/* Delayed */
	{
		/* Set timer (in seconds) */
		shutdown_timer= min * 60;
	}
}
开发者ID:jjrh,项目名称:mangband,代码行数:22,代码来源:control.c


示例4: main

int main(int argc, char** argv) {

    int port = atoi(argv[1]);

    Server* server = create_server(port);

    listen_port(server);

    Connection* con = accept_connection(server);

    char client_addr[50];
    get_connection_address(con, client_addr);

    printf("CLIENT %s CONNECTED\n", client_addr);

    receive_greet(con);
    send_greet_ack(con);


    //Receive folder anem
    char buffer[MAX_MSG];
    receive_msg(con, buffer);
    send_ack(con);

    char filename[100];
    strcpy(filename, client_addr);
    strcat(filename, buffer);

    int i;
    for(i = 0; filename[i] != '\0'; i++){
        filename[i] = filename[i] == '/'? '.': filename[i];
    }

    char* filebuffer = calloc(sizeof(char), MAX_MSG);
    int filebuffer_size = MAX_MSG;
    filebuffer[0] = '\0';

    int usedbuffer = 0;

    //receive filenames
    while(receive_msg(con, buffer)){
        usedbuffer += strlen(buffer)+1;
        if(usedbuffer > filebuffer_size){
            filebuffer_size *= 2;
            filebuffer = (char*) realloc(filebuffer, sizeof(char)*filebuffer_size*2);
        }
        printf("%s\n", buffer);
        sprintf(filebuffer, "%s%s\n", filebuffer, buffer);
        send_ack(con);
    }

    shutdown_server(server);
    close_connection(con);

    FILE* f = fopen(filename, "w");
    fprintf(f, "%s", filebuffer);
    fclose(f);

    free(filebuffer);


    return 0;
}
开发者ID:ivan94,项目名称:UFMG-152-Networks,代码行数:63,代码来源:main_server.c


示例5: main

/**
 * Point d'entrée du programme.
 */
int main(int argc, char *argv[])
{
  parse_command_line(argc, argv);
  
  /* On crée un socket pour se connecter sur un serveur */
  if ((server_socket = socket(PF_INET, SOCK_STREAM, 0)) == -1)
    {
      perror("socket");
      return EXIT_FAILURE;
    }
  
  /* Initialisation du bind */
  memset(&server_address, 0, sizeof server_address);
  server_address.sin_family = AF_INET;
  server_address.sin_addr.s_addr = htonl(INADDR_ANY);
  server_address.sin_port = htons(port);
  
  /* Ze bind  */
  if (bind(server_socket, (struct sockaddr *) &server_address, sizeof(server_address)) == -1)
    {
      perror("bind");
      if (close(server_socket) == -1)
	perror("Impossible de fermer le socket serveur");
      return EXIT_FAILURE;
    }
  
  /* On le définit comme écouteur */
  if (listen(server_socket, MAX_CLIENT) == -1)
    {
      perror("Impossible de mettre le socket serveur en écoute");
      if (close(server_socket) == -1)
	perror("Impossible de fermer le socket serveur");
      return EXIT_FAILURE;
    }
  
  verbose("Démarrage du démon sur le port %d ...\n", port);
  
  /* Pour quitter le serveur proprement  */
  signal(SIGINT, trap_ctrlc);
  
  for (;;) {
    
    /* Variable concrète car il faut pouvoir en avoir l'adresse pour accept() */
    socklen_t client_address_size = sizeof client_address;
    
    /* On attend une connection */
    if ((client_socket = accept(server_socket, (struct sockaddr *) &client_address, &client_address_size)) == -1)
      {
	perror("accept");
	if (close(server_socket) == -1)
	  perror("Impossible de fermer le socket serveur");
	return EXIT_FAILURE;
      }
    
    /* On traite ce client */
    process_client();
  }
  
  shutdown_server(); /* N'arrivera jamais */
  
  return EXIT_FAILURE;
}
开发者ID:BackupTheBerlios,项目名称:cadi,代码行数:65,代码来源:cadid.c


示例6: trap_ctrlc

/**
 * Fonction de callback appelée lors d'un ctrl+c.
 */
static void trap_ctrlc(int sig)
{
  sig = sig;                  /* Evite un warning */
  shutdown_server();
}
开发者ID:BackupTheBerlios,项目名称:cadi,代码行数:8,代码来源:cadid.c


示例7: exec_shutdown_maxscale

/**
 * MaxScale shutdown
 * @param dcb Client DCB
 * @param tree Parse tree
 */
void exec_shutdown_maxscale(DCB *dcb, MAXINFO_TREE *tree)
{
    shutdown_server();
    maxinfo_send_ok(dcb);
}
开发者ID:bigshuai,项目名称:MaxScale,代码行数:10,代码来源:maxinfo_exec.c


示例8: main


//.........这里部分代码省略.........


    /* initialize webserver */
    if (!init_server(crtpath, qpath, rqpath, lsthost, lstport)) {
        flog(LOG_ERR, "failed to initialize webserver");
        return EXIT_FAILURE;
    }


    /* try to reregister watches as long as no signal caught */
    for (lastclock = getmontime(), retryid = 0;  !stop_requested(); ) {
        /* support empty CABLE_NOLOOP when testing, to act as pure server */
#ifdef TESTING
        if (getenv("CABLE_NOLOOP")) {
            sleepsec(RETRY_TMOUT);
            continue;
        }
#endif

        wait_reg_watches(qpath, rqpath);

        /* read events as long as no signal caught and no unmount / move_self / etc. events read */
        for (rereg = evqok = 0;  !stop_requested()  &&  !rereg; ) {
            /* wait for an event, or timeout (later blocking read() results in error) */
            retrytmout = RETRY_TMOUT + RETRY_TMOUT * (rand_shift() / 2);

            if (wait_read(inotfd, retrytmout - (getmontime() - lastclock))) {
                /* read events (non-blocking), taking care to handle interrupts due to signals */
                if ((sz = read(inotfd, buf, sizeof(buf))) == -1  &&  errno != EINTR) {
                    /* happens buffer is too small (e.g., NTFS + 255 unicode chars) */
                    warning("error while reading from inotify queue");
                    rereg = 1;
                }

                /* process all events in buffer, sz = -1 and 0 are automatically ignored */
                for (offset = 0;  offset < sz  &&  !stop_requested()  &&  !rereg;  evqok = 1) {
                    /* get handler to next event in read buffer, and update offset */
                    iev     = (struct inotify_event*) (buf + offset);
                    offset += sizeof(struct inotify_event) + iev->len;

                    /*
                      IN_IGNORED is triggered by watched directory removal / fs unmount
                      IN_MOVE_SELF is only triggered by move of actual watched directory
                      (i.e., not its parent)
                    */
                    if ((iev->mask & (IN_IGNORED | IN_UNMOUNT | IN_Q_OVERFLOW | IN_MOVE_SELF)))
                        rereg = 1;

                    /* ignore non-subdirectory events, and events with incorrect name */
                    else if (iev->len > 0  &&  (iev->mask & IN_ISDIR)  &&  is_msgdir(iev->name)) {
                        assert(iev->wd == inotqwd  ||  iev->wd == inotrqwd);
                        if (iev->wd == inotqwd  ||  iev->wd == inotrqwd) {
                            /* stop can be indicated here (while waiting for less processes) */
                            const char *qtype = (iev->wd == inotqwd) ? QUEUE_NAME : RQUEUE_NAME;
                            run_loop(qtype, iev->name, looppath);
                        }
                        else
                            flog(LOG_WARNING, "unknown watch descriptor");
                    }
                }
            }

            /*
              if sufficient time passed since last retries, retry again
            */
            if (!stop_requested()  &&  getmontime() - lastclock >= retrytmout) {
                /* alternate between queue dirs to prevent lock starvation on self-send */
                if ((retryid ^= 1))
                    retry_dir(QUEUE_NAME,  qpath,  looppath);
                else
                    retry_dir(RQUEUE_NAME, rqpath, looppath);

                lastclock = getmontime();

                /* inotify is apparently unreliable on fuse, so reregister when no events */
                if (!evqok)
                    rereg = 1;
                evqok = 0;
            }
        }
    }


    unreg_watches();

    if (!shutdown_server())
        flog(LOG_WARNING, "failed to shutdown webserver");

    dealloc_env(lstport);
    dealloc_env(lsthost);
    dealloc_env(looppath);
    dealloc_env(rqpath);
    dealloc_env(qpath);
    dealloc_env(crtpath);

    flog(LOG_INFO, "exiting");
    closelog();

    return EXIT_SUCCESS;
}
开发者ID:carriercomm,项目名称:cables,代码行数:101,代码来源:daemon.c


示例9: iuctl_server_shutdown

void iuctl_server_shutdown() {
    destroy_iuctl();
    shutdown_server();
    exit(0);
}
开发者ID:wjmelements,项目名称:iu,代码行数:5,代码来源:iuctl_server.cpp



注:本文中的shutdown_server函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ si470x_set_register函数代码示例发布时间:2022-05-30
下一篇:
C++ shuffle函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap