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

C++ server_start函数代码示例

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

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



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

示例1: main

int main()
{
	//init win32 socket
#ifdef __WIN32__
	static WSADATA wsa_data; 
	int result = WSAStartup((WORD)(1<<8|1), &wsa_data); //初始化WinSocket动态连接库
	if( result != 0 ) // 初始化失败
		return -1;
#endif
#ifndef __WIN32__
	signal( SIGPIPE, SIG_IGN );	//ignore send,recv SIGPIPE error
#endif
	NEW( websrv, sizeof(webserver) );
	memset( websrv, 0, sizeof(webserver) );
	server_create( websrv, "config.xml" );
	server_start( websrv );
	do_console();
	server_stop( websrv );
	server_end( websrv );
	DEL( websrv );

#ifdef __WIN32__
	WSACleanup();
#endif
	memory_end();
	return 0;
}
开发者ID:zhao9jack,项目名称:fox2,代码行数:27,代码来源:main.c


示例2: main

int main(int argv,char **args)
{
	int ret,epfd,nfds,server_socket_fd,i,index;
	struct epoll_event events[256];
	int count;	

	server_socket_fd = server_start();	
	if(server_socket_fd<0)
	{
		return 0;
	}
	set_non_blocking(server_socket_fd);

	epfd = epoll_create(1024);
	set_non_blocking(epfd);
	epoll_add(epfd,server_socket_fd);

	struct http_request_r *r=NULL,*p=NULL;

        while(1)
        {
                nfds=epoll_wait(epfd,events,20,500);
                for(i=0;i<nfds;i++)
                {
                        if(events[i].data.fd==server_socket_fd)
                        {
				onAccept(epfd,events[i],&r);
			}
                        else if(events[i].events&EPOLLIN)
                        {
				onData(epfd,events[i],&r);
                        }
                }
        }
}
开发者ID:pqzhou2005,项目名称:tests,代码行数:35,代码来源:server.c


示例3: main

// ---------------------------------- main() --------------------------------
int main(int argc, char *argv[]) {
  if (argc == 2)                            //if you input 2 arguments, then the first input becomes the port number
    portno = atoi(argv[1]);

  server_start();
  return 0;
}
开发者ID:heliumsoule,项目名称:Database-Storage--LifeTracker-,代码行数:8,代码来源:myStore.c


示例4: csiebox_server_init

//read config file, and start to listen
void csiebox_server_init(/*{{{*/
  csiebox_server** server, int argc, char** argv) {
  csiebox_server* tmp = (csiebox_server*)malloc(sizeof(csiebox_server));
  if (!tmp) {
    fprintf(stderr, "server malloc fail\n");
    return;
  }
  memset(tmp, 0, sizeof(csiebox_server));
  if (!parse_arg(tmp, argc, argv)) {
    fprintf(stderr, "Usage: %s [config file]\n", argv[0]);
    free(tmp);
    return;
  }
  int fd = server_start();
  if (fd < 0) {
    fprintf(stderr, "server fail\n");
    free(tmp);
    return;
  }
  tmp->client = (csiebox_client_info**)
      malloc(sizeof(csiebox_client_info*) * getdtablesize());
  if (!tmp->client) {
    fprintf(stderr, "client list malloc fail\n");
    close(fd);
    free(tmp);
    return;
  }
  memset(tmp->client, 0, sizeof(csiebox_client_info*) * getdtablesize());
  tmp->listen_fd = fd;
  *server = tmp;
}
开发者ID:qhan1028,项目名称:SP2015,代码行数:32,代码来源:csiebox_server.c


示例5: main

int main(int argc, char **argv) {
	int port, gamespeed;

	if (argc < 4) {
		fprintf(stdout, "Usage: %s <map> <gamespeed (1-10)> <players> [port]\n", argv[0]);
		return -1;
	}

	if (argc >= 5)
		port = atoi(argv[4]);
	else
		port = SERVER_PORT_DEFAULT;

	fprintf(stderr, "Listening on port %i...\n", port);
	server_init();
	gettimeofday(&time_d, NULL);
	gamespeed = atoi(argv[2]);

	if (server_start(argv[1], atoi(argv[3]), port, gamespeed) == NULL)
		return -1;
	for (;;) {
		server_loop(deltaTime());
		#ifdef _WIN32
		Sleep(15);
		#else
		usleep(15000);
		#endif
	}

	
	return 0;
}
开发者ID:slaeshjag,项目名称:Muon,代码行数:32,代码来源:main.c


示例6: main

int main(int argc, char* argv[])
{
    int id = 0;
    if (argc >= 2)
    {
        id = atoi(argv[1]);
    }

    int i=0;
    for (;i<argc; i++)
    {
        if (strcmp(argv[i], "-d") == 0)
        {
            init_daemon();
            break;
        }
    }

    server_start(id);

    while (1)
    {
        sleep(60);
    }

    server_shutdown();

    return 0;
}
开发者ID:quinsmpang,项目名称:phone-code,代码行数:29,代码来源:main.cpp


示例7: main

int main(int argc, char *argv[]) {
	server_setup_signals();
	server_parse_params(argc, argv);
	server_printopts();
	server_start();
	return 0;
}
开发者ID:coderbyheart,项目名称:hsrm-mi-bsra,代码行数:7,代码来源:netcpd.c


示例8: init

/* Module functions */
static int
init(const struct mpdcron_config *conf, GKeyFile *fd)
{
	GError *error;
	g_debug("Initializing");

	/* Load configuration */
	if (file_load(conf, fd) < 0)
		return MPDCRON_INIT_FAILURE;

	/* Initialize database */
	error = NULL;
	if (!db_init(globalconf.dbpath, true, false, &error)) {
		g_critical("Failed to initialize database `%s': %s",
				globalconf.dbpath, error->message);
		g_error_free(error);
		file_cleanup();
		return MPDCRON_INIT_FAILURE;
	}

	/* Initialize, bind and start the server */
	server_init();
	for (unsigned int i = 0; globalconf.addrs[i] != NULL; i++) {
		if (strncmp(globalconf.addrs[i], "any", 4) == 0)
			server_bind(NULL, globalconf.port);
		else if (globalconf.addrs[i][0] == '/')
			server_bind(globalconf.addrs[i], -1);
		else
			server_bind(globalconf.addrs[i], globalconf.port);
	}
	server_start();

	timer = g_timer_new();
	return MPDCRON_INIT_SUCCESS;
}
开发者ID:hariskar,项目名称:mpdcron,代码行数:36,代码来源:stats-module.c


示例9: hsn_node_setup

int		hsn_node_setup(t_hsn_node *node,
			       const char *credentials_dirpath,
			       const char *peers_list_filepath,
			       const char *peers_dirpath,
			       int port)
{
  fprintf(stderr, "HSN node setup:\n");
  fprintf(stderr, "* Loading credentials...\n");
  if (hsn_node_load_credentials(node, credentials_dirpath) != 0)
    goto err_load_credentials;
  fprintf(stderr, "* Loading peers...\n");
  if (hsn_node_load_peers(node, peers_list_filepath, peers_dirpath) != 0)
    goto err_load_peers;
  fprintf(stderr, "* Connecting to peers...\n");
  if (hsn_node_connect_to_peers(node) != 0)
    goto err_connect_to_peers;
  fprintf(stderr, "* Starting server...\n");
  node->server.port = port;
  if (server_start(node) != 0)
    goto err_start_server;
  fprintf(stderr, "done.\n\n");
  return (0);

 err_start_server:
  hsn_node_disconnect_from_peers(node);
 err_connect_to_peers:
  hsn_node_unload_peers(node);
 err_load_peers:
  hsn_node_unload_credentials(node);
 err_load_credentials:
  return (1);
}
开发者ID:yoones,项目名称:hsn,代码行数:32,代码来源:hsn_node_setup.c


示例10: main

int main(int argc, char **argv) {
	server_t srv = server_init("0.0.0.0", 5431, test_onmessage, test_onconnect, test_ondisconnect);
	if (!server_start(srv)) {
		return EXIT_FAILURE;
	}
	server_loop(srv);
	return EXIT_SUCCESS;
}
开发者ID:nagyist,项目名称:pg_dtm,代码行数:8,代码来源:server.c


示例11: test

void test()
{
    server = epollserver_create(HTTP_PORT, MAX_CLIENT_NUM, 1024, 1024);
    printf("EAGAIN is %d\n", EAGAIN);
    printf("ECONNRESET is %d\n", ECONNRESET);
    
    server_start(server, my_logic_on_enter_pt, my_logic_on_close_pt, my_logic_on_recved_pt);
}
开发者ID:GodZza,项目名称:accumulation-dev,代码行数:8,代码来源:main.c


示例12: mu_assert

char *test_server_start()
{
    mu_assert("Starting server", server_start("::1","3141",1,&pid) == 0);
    mu_assert("Ensure we have pid for daemon", pid > 0);
    mu_assert("Verify pid is valid", kill(pid, 0) == 0);

    return 0;
}
开发者ID:brettsheffield,项目名称:gladbooks,代码行数:8,代码来源:server_test.c


示例13: main

int main(int argc, char *argv[]) {
	short port;

	port = get_port(argc, argv);
	server_start(port, (callback_t) &handle); /* infinite loop */

	return EXIT_SUCCESS; /* to make gcc happy */
}
开发者ID:phluid61,项目名称:http2-experimental,代码行数:8,代码来源:main.c


示例14: main

int main(int argc, char *argv[]) {
    Server *server = create_server();

    server->port = PORT;
    server->handler = &handler;
    server_start(server);

    return 0;
}
开发者ID:clemenation,项目名称:FileTransfer,代码行数:9,代码来源:server.c


示例15: main

int main(int argc, char const* argv[]) {
  server_t* s;
  sigset_t mask;
  siginfo_t info;
  struct sigaction action;

  if(argc == 1) {
    if(!server_create(&s, "../calories.csv", NULL)) {
      if(!server_create(&s, "./calories.csv", NULL)) {
        printf("File '%s' fot found\n", "calories.csv");
        exit(1);
      }
    }
  } else if(argc == 2) {
    if(!server_create(&s, "../calories.csv", argv[1])) {
      if(!server_create(&s, "./calories.csv", argv[1])) {
        printf("File '%s' fot found\n", "calories.csv");
        exit(1);
      }
    }
  } else {
    printf("%s\n", SERVER_MAIN_HELP);
    exit(1);
  }

  printf("Press CTRL+C to shutdown the server\n");

  sigemptyset(&mask);
  sigaddset(&mask, SIGINT);
  sigprocmask(SIG_BLOCK, &mask, NULL);

  sigemptyset(&action.sa_mask);
  action.sa_flags = SA_SIGINFO;
  sigaction(SIGCHLD, &action, NULL);

  if(server_start(s)) {
    while(true) {
      // signal() is NOT thread safe!
      // And since the server doesn't block signal handling is "not" needed ...
      if(sigwaitinfo(&mask, &info) == -1) {
        perror("sigwaitinfo() failed");
        exit(1);
      }

      switch(info.si_signo) {
      case SIGINT:
        server_destroy(s);
        return 0;
      }
    }
  } else {
    server_destroy(s);
  }
}
开发者ID:Eyenseo,项目名称:Nutrition-Server-Client,代码行数:54,代码来源:main.c


示例16: hid_server_probe

static int hid_server_probe(struct btd_profile *p, struct btd_adapter *adapter)
{
	int ret;

	ret = server_start(adapter_get_address(adapter));
	if (ret < 0)
		return ret;

	adapters = g_slist_append(adapters, btd_adapter_ref(adapter));

	return 0;
}
开发者ID:intgr,项目名称:bluez,代码行数:12,代码来源:manager.c


示例17: server_init

void server_init()
{
    servers = pmap_new(cstr_t)();

    if (!os_getenv("NEOVIM_LISTEN_ADDRESS")) {
        char *listen_address = (char *)vim_tempname('s');
        os_setenv("NEOVIM_LISTEN_ADDRESS", listen_address, 1);
        free(listen_address);
    }

    server_start((char *)os_getenv("NEOVIM_LISTEN_ADDRESS"));
}
开发者ID:jkbianchi,项目名称:neovim,代码行数:12,代码来源:server.c


示例18: server_init

/// Initializes the module
void server_init(void)
{
  servers = pmap_new(cstr_t)();

  if (!os_getenv(LISTEN_ADDRESS_ENV_VAR)) {
    char *listen_address = (char *)vim_tempname();
    os_setenv(LISTEN_ADDRESS_ENV_VAR, listen_address, 1);
    free(listen_address);
  }

  server_start((char *)os_getenv(LISTEN_ADDRESS_ENV_VAR));
}
开发者ID:ChrisBuchholz,项目名称:neovim,代码行数:13,代码来源:server.c


示例19: main

int main(int argc, char **argv)
{
    if (argc > 1 && !strcmp(argv[1], "--server")) {
        if (argc > 2 && !strcmp(argv[2], "--pc"))
            server_start(PLAYER_PC);
        else
            server_start(PLAYER_HUMAN);
    }
    else if (argc > 1 && !strcmp(argv[1], "--client")) {
        if (argc > 2 && !strcmp(argv[2], "--pc"))
            client_start(PLAYER_PC);
        else
            client_start(PLAYER_HUMAN);
    }
    else {
        printf("Usage:\n");
        printf("    %s --server         Start Server (Player 1)\n", argv[0]);
        printf("    %s --client         Start Client (Player 2)\n", argv[0]);
        printf("    %s [......] --pc    Start as PC Player\n", argv[0]);
    }

    return 0;
}
开发者ID:ynov,项目名称:tictactoe_ipc,代码行数:23,代码来源:main.c


示例20: main

int main(int argc, char **argv)
{
	enum start_mode mode = NONE;

	while (1) {
		int index, c;

		c = getopt_long(argc, argv, short_options, long_options, &index);
		if (c == -1)
			break;

		switch (c) {
		case 0:
			break;

		case 'd':
			debug = 1;
			break;

		case 'm':
			if (strcmp(optarg, "server") == 0)
				mode = SERVER;
			else if (strcmp(optarg, "client") == 0)
				mode = CLIENT;
			break;
			
		case 'h':
			usage(stdout, argv);
			exit(EXIT_SUCCESS);

		default:
			usage(stderr, argv);
			exit(EXIT_FAILURE);
		}
	}

	switch (mode) {
	case CLIENT:
		client_start();
		break;
	case SERVER:
		server_start();
		break;
	case NONE:
		usage(stderr, argv);
		exit(EXIT_FAILURE);
	}

	return 0;
}
开发者ID:jiayisuse,项目名称:tele_sync,代码行数:50,代码来源:dartsync.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ service函数代码示例发布时间:2022-05-30
下一篇:
C++ server_get_network函数代码示例发布时间: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