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

C++ server_connect函数代码示例

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

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



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

示例1: run

static int run(void)
{
	int i, ret = 0;

	buf = malloc(!custom ? test_size[TEST_CNT - 1].size : transfer_size);
	if (!buf) {
		perror("malloc");
		return -1;
	}

	if (!dst_addr) {
		ret = server_listen();
		if (ret)
			goto free;
	}

	printf("%-10s%-8s%-8s%-8s%-8s%8s %10s%13s\n",
	       "name", "bytes", "xfers", "iters", "total", "time", "Gb/sec", "usec/xfer");
	if (!custom) {
		optimization = opt_latency;
		ret = dst_addr ? client_connect() : server_connect();
		if (ret)
			goto free;

		for (i = 0; i < TEST_CNT; i++) {
			if (test_size[i].option > size_option)
				continue;
			init_latency_test(test_size[i].size);
			run_test();
		}
		rshutdown(rs, SHUT_RDWR);
		rclose(rs);

		optimization = opt_bandwidth;
		ret = dst_addr ? client_connect() : server_connect();
		if (ret)
			goto free;
		for (i = 0; i < TEST_CNT; i++) {
			if (test_size[i].option > size_option)
				continue;
			init_bandwidth_test(test_size[i].size);
			run_test();
		}
	} else {
		ret = dst_addr ? client_connect() : server_connect();
		if (ret)
			goto free;

		ret = run_test();
	}

	rshutdown(rs, SHUT_RDWR);
	rclose(rs);
free:
	free(buf);
	return ret;
}
开发者ID:VinGorilla,项目名称:gpunet,代码行数:57,代码来源:riostream.c


示例2: rtsp_connect

/*
 * set basic stuff and send OPTIONS request.
 * this can be used to determine  which protocol to use,
 * depending on its server.
 *              return value    sock : success
 *                                -1 : failure
 */
int rtsp_connect(struct stream_t *stream)
{
    int sock;
    struct stream_ctrl_t *stream_ctrl = stream->stream_ctrl;
    struct rtsp_ctrl_t *rtsp_ctrl = stream_ctrl->rtsp_ctrl;
    struct url_t *url = stream->url;
    
    
    set_serverinfo(stream->serverinfo,url->hostname,url->port,NULL,0,RTSP_PORT);
  
    rtsp_ctrl->server = NULL;
    rtsp_ctrl->cseq = 1;
    rtsp_ctrl->server_state = 0;
    rtsp_ctrl->server_caps  = 0;
    rtsp_ctrl->session = NULL;
    rtsp_ctrl->get_media_packet = NULL;
    /* make mrl */
    rtsp_make_mrl(rtsp_ctrl,stream->serverinfo->host,stream->serverinfo->port,url->filepath);

    sock = server_connect(stream->serverinfo->connect_host,stream->serverinfo->connect_port);
    if(sock < 0) { /* couldn't connect for some reason. (port closed maybe) */
	goto failed;
    }

    
    stream->netsock->sock = sock; /* save socket id */
    return sock;

  failed:
    return -1;
}
开发者ID:clkao,项目名称:msdl,代码行数:38,代码来源:rtsp.c


示例3: sync_connect

int sync_connect(struct sync_device *d, const char *host, unsigned short port)
{
	int i;
	if (d->sock != INVALID_SOCKET)
		closesocket(d->sock);

	d->sock = server_connect(host, port);
	if (d->sock == INVALID_SOCKET)
		return -1;

	for (i = 0; i < (int)d->num_tracks; ++i) {
		free(d->tracks[i]->keys);
		d->tracks[i]->keys = NULL;
		d->tracks[i]->num_keys = 0;
	}

	for (i = 0; i < (int)d->num_tracks; ++i) {
		if (get_track_data(d, d->tracks[i])) {
			closesocket(d->sock);
			d->sock = INVALID_SOCKET;
			return -1;
		}
	}
	return 0;
}
开发者ID:fcondolo,项目名称:rocket,代码行数:25,代码来源:device.c


示例4: server_method

static zmsg_t *
server_method (server_t *self, const char *method, zmsg_t *msg)
{
    //  Connect to a remote
    zmsg_t *reply = NULL;
    if (streq (method, "CONNECT")) {
        char *endpoint = zmsg_popstr (msg);
        assert (endpoint);
        server_connect (self, endpoint);
        zstr_free (&endpoint);
    }
    else
    if (streq (method, "PUBLISH")) {
        char *key = zmsg_popstr (msg);
        char *value = zmsg_popstr (msg);
        server_accept (self, key, value);
        zstr_free (&key);
        zstr_free (&value);
    }
    else
    if (streq (method, "STATUS")) {
        //  Return number of tuples we have stored
        reply = zmsg_new ();
        assert (reply);
        zmsg_addstr (reply, "STATUS");
        zmsg_addstrf (reply, "%d", (int) zhashx_size (self->tuples));
    }
    else
        zsys_error ("unknown zgossip method '%s'", method);

    return reply;
}
开发者ID:Cargo-Labs,项目名称:czmq,代码行数:32,代码来源:zgossip.c


示例5: server_each_preconnect

static rstatus_t
server_each_preconnect(void *elem, void *data)
{
	rstatus_t status;
	struct server *server;
	struct server_pool *pool;
	struct conn *conn;

	server = elem;
	pool = server->owner;

	conn = server_conn(server);
	if (conn == NULL) {
		return DN_ENOMEM;
	}

	status = server_connect(pool->ctx, server, conn);
	if (status != DN_OK) {
		log_warn("connect to server '%.*s' failed, ignored: %s",
				server->pname.len, server->pname.data, strerror(errno));
		server_close(pool->ctx, conn);
	}

	return DN_OK;
}
开发者ID:mbrukman,项目名称:netflix-dynomite,代码行数:25,代码来源:dyn_server.c


示例6: run

static int run(void)
{
	int ret = 0;

	if (!dst_addr) {
		ret = server_listen();
		if (ret)
			return ret;
	}

	ret = dst_addr ? client_connect() : server_connect();
	if (ret) {
		return ret;
	}

	run_test();

	fi_shutdown(ep, 0);
	fi_close(&ep->fid);
	free_ep_res();
	if (!dst_addr)
		free_lres();
	fi_close(&dom->fid);
	fi_close(&fab->fid);
	return ret;
}
开发者ID:rfaucett,项目名称:fabtests,代码行数:26,代码来源:imm_data.c


示例7: server_pool_conn

struct conn *
server_pool_conn(struct context *ctx, struct server_pool *pool, uint8_t *key,
                 uint32_t keylen)
{
    rstatus_t status;
    struct server *server;
    struct conn *conn;

    status = server_pool_update(pool);
    if (status != NC_OK) {
        return NULL;
    }

    /* from a given {key, keylen} pick a server from pool */
    server = server_pool_server(pool, key, keylen);
    if (server == NULL) {
        return NULL;
    }

    /* pick a connection to a given server */
    conn = server_conn(server);
    if (conn == NULL) {
        return NULL;
    }

	//log_error("tyson tyson tyson: %p", TAILQ_FIRST(&server->s_conn_q));

    status = server_connect(ctx, server, conn);
    if (status != NC_OK) {
        server_close(ctx, conn);
        return NULL;
    }

    return conn;
}
开发者ID:Bilibili,项目名称:bilitw,代码行数:35,代码来源:nc_server.c


示例8: server_init_process

/***********************************************************************
 *           server_init_process
 *
 * Start the server and create the initial socket pair.
 */
void server_init_process(void)
{
    obj_handle_t dummy_handle;
    const char *env_socket = getenv( "WINESERVERSOCKET" );

    if (env_socket)
    {
        fd_socket = atoi( env_socket );
        if (fcntl( fd_socket, F_SETFD, 1 ) == -1)
            fatal_perror( "Bad server socket %d", fd_socket );
        unsetenv( "WINESERVERSOCKET" );
    }
    else fd_socket = server_connect();

    /* setup the signal mask */
    sigemptyset( &server_block_set );
    sigaddset( &server_block_set, SIGALRM );
    sigaddset( &server_block_set, SIGIO );
    sigaddset( &server_block_set, SIGINT );
    sigaddset( &server_block_set, SIGHUP );
    sigaddset( &server_block_set, SIGUSR1 );
    sigaddset( &server_block_set, SIGUSR2 );
    sigaddset( &server_block_set, SIGCHLD );
    pthread_functions.sigprocmask( SIG_BLOCK, &server_block_set, NULL );

    /* receive the first thread request fd on the main socket */
    ntdll_get_thread_data()->request_fd = receive_fd( &dummy_handle );

#ifdef __APPLE__
    send_server_task_port();
#endif
}
开发者ID:iamfil,项目名称:wine,代码行数:37,代码来源:server.c


示例9: server_pool_conn

struct conn *
server_pool_conn(struct context *ctx, struct server_pool *pool, uint8_t *key,
		uint32_t keylen)
{
	rstatus_t status;
	struct server *server;
	struct conn *conn;

	status = server_pool_update(pool);
	if (status != DN_OK) {
		return NULL;
	}

	/* from a given {key, keylen} pick a server from pool */
	server = server_pool_server(pool, key, keylen);
	if (server == NULL) {
		return NULL;
	}

	/* pick a connection to a given server */
	conn = server_conn(server);
	if (conn == NULL) {
		return NULL;
	}

	status = server_connect(ctx, server, conn);
	if (status != DN_OK) {
		server_close(ctx, conn);
		return NULL;
	}

	return conn;
}
开发者ID:mbrukman,项目名称:netflix-dynomite,代码行数:33,代码来源:dyn_server.c


示例10: cfg_conf_server_connect

/* server connect <servertag> */
bool cfg_conf_server_connect(struct cfg_state *cmd, char *args)
{
	int		fields = countfields(args);
	char		tag[25], var[25], val[1000];
	struct server	*srv;
	struct channel	*ch;

	/* Add requires 1 variables */
	if (	fields != 1 ||
		!copyfield(args, 1, tag, sizeof(tag)))
	{
		sock_printf(cmd->sock, "400 The command is: server connect <servertag>\n");
		return false;
	}

	srv = server_find_tag(tag);

	if (!srv)
	{
		sock_printf(cmd->sock, "400 Server '%s' does not exist\n");
		return false;
	}
	
	server_connect(srv);

	sock_printf(cmd->sock, "200 Connecting to server\n");
	return true;
}
开发者ID:massar,项目名称:talamasca,代码行数:29,代码来源:config.c


示例11: sentinel_connect

struct conn *
sentinel_connect(struct context *ctx)
{
    rstatus_t status;
    struct conn *conn;
    int cmd_num;
    int i;

    ASSERT(sentinel_status == SENTINEL_CONN_DISCONNECTED);

    /* get the only connect of sentinel */
    conn = sentinel_conn(ctx->sentinel);
    if (conn == NULL) {
        return NULL;
    }

    status = server_connect(ctx, ctx->sentinel, conn);
    if(status != NC_OK) {
        sentinel_close(ctx, conn);
        return NULL;
    }

    cmd_num = sizeof(sentinel_req_cmds) / sizeof(char *);
    for (i = 0; i < cmd_num; i++) {
        status = req_construct(ctx, conn, sentinel_req_cmds[i]);
        if(status != NC_OK) {
            sentinel_close(ctx, conn);
            return NULL;
        }
    }

    sentinel_status = SENTINEL_CONN_SEND_REQ;

    return conn;
}
开发者ID:happydayxiaoz,项目名称:bdrp,代码行数:35,代码来源:nc_sentinel.c


示例12: reconnect_all

static void reconnect_all(void)
{
	GSList *list;
	SERVER_CONNECT_REC *conn;
	RECONNECT_REC *rec;

	/* first move reconnects to another list so if server_connect()
	   fails and goes to reconnection list again, we won't get stuck
	   here forever */
	list = NULL;
	while (reconnects != NULL) {
		rec = reconnects->data;

		list = g_slist_append(list, rec->conn);
                server_connect_ref(rec->conn);
		server_reconnect_destroy(rec);
	}


	while (list != NULL) {
		conn = list->data;

		server_connect(conn);
                server_connect_unref(conn);
                list = g_slist_remove(list, conn);
	}
}
开发者ID:FauxFaux,项目名称:irssi,代码行数:27,代码来源:servers-reconnect.c


示例13: run

static int run(void)
{
	int ret = 0;

	addr_array = calloc(ep_cnt, sizeof(*addr_array));
	if (!addr_array) {
		perror("malloc");
		return -FI_ENOMEM;
	}

	if (hints->ep_attr->type == FI_EP_MSG) {
		if (!opts.dst_addr) {
			ret = ft_start_server();
			if (ret)
				return ret;
		}

		ret = opts.dst_addr ? client_connect() : server_connect();
	} else {
		ret = init_fabric();
	}
	if (ret)
		return ret;

	ret = run_test();

	/* TODO: Add a local finalize applicable to shared ctx */
	//ft_finalize(fi, ep_array[0], txcq, rxcq, addr_array[0]);
	return ret;
}
开发者ID:ofiwg,项目名称:libfabric,代码行数:30,代码来源:shared_ctx.c


示例14: server_reconnect_timeout

static int server_reconnect_timeout(void)
{
	SERVER_CONNECT_REC *conn;
	GSList *list, *tmp;
	time_t now;

	/* If server_connect() removes the next reconnection in queue,
	   we're screwed. I don't think this should happen anymore, but just
	   to be sure we don't crash, do this safely. */
	list = g_slist_copy(reconnects);
	now = time(NULL);
	for (tmp = list; tmp != NULL; tmp = tmp->next) {
		RECONNECT_REC *rec = tmp->data;

		if (g_slist_find(reconnects, rec) == NULL)
			continue;

		if (rec->next_connect <= now) {
			conn = rec->conn;
			server_reconnect_destroy(rec, FALSE);
			server_connect(conn);
		}
	}

	g_slist_free(list);
	return 1;
}
开发者ID:svn2github,项目名称:irssi,代码行数:27,代码来源:servers-reconnect.c


示例15: main

int main(int argc, char* argv[])
{
    GtkWidget *window;
    GtkWidget *inc_button, *dec_button;
    GtkWidget *hbox1;
    GtkWidget *vbox1;
    GtkWidget *label1;

    pthread_t thread;
    long t = 0;

    serverConnected = 0;

    if (server_connect(1) == 1)
    {
        pthread_create(&thread, NULL, listener_thread, (void*)t);

        gtk_init(&argc, &argv);

        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_title(GTK_WINDOW(window), "Opal6 ThingFabric Demo");
        gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
        gtk_window_set_default_size(GTK_WINDOW(window), 250, 50);

        g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(closeApp), NULL);

        dec_button = gtk_button_new_with_label("  DOWN  ");
        g_signal_connect(G_OBJECT(dec_button), "clicked", G_CALLBACK(temp_button_clicked), "-");

        inc_button = gtk_button_new_with_label("    UP    ");
        g_signal_connect(G_OBJECT(inc_button), "clicked", G_CALLBACK(temp_button_clicked), "+");

        label1 = gtk_label_new("Temperature");
        tempLabel = gtk_label_new("25C");
        publish_temp(temp);  // send the initial value

        vbox1 = gtk_vbox_new(TRUE, 1);
        gtk_box_pack_start(GTK_BOX(vbox1), label1, TRUE, FALSE, 1);
        gtk_box_pack_start(GTK_BOX(vbox1), tempLabel, TRUE, FALSE, 1);

        hbox1 = gtk_hbox_new(TRUE, 5);
        gtk_box_pack_start(GTK_BOX(hbox1), dec_button, TRUE, FALSE, 5);
        gtk_box_pack_start(GTK_BOX(hbox1), vbox1, TRUE, FALSE, 5);
        gtk_box_pack_start(GTK_BOX(hbox1), inc_button, TRUE, FALSE, 5);

        gtk_container_add(GTK_CONTAINER(window), hbox1);

        gtk_widget_show_all(window);
        gtk_main();
    }
    else
    {
        printf("Error: Unable to connect to ThingFabric server\n");
    }

    return 0;
}
开发者ID:DeviceSolutions,项目名称:meta-opal6-demos,代码行数:57,代码来源:opal6-demo.c


示例16: GetConnection

s32 GetConnection(char * domain) {

    u32 ipaddress = getipbynamecached(domain);
    if(ipaddress == 0) {
        return -1;
    }
    s32 connection = server_connect(ipaddress, 80);
    return connection;

}
开发者ID:fishears,项目名称:wiicoverflow,代码行数:10,代码来源:http.c


示例17: main

int main(int argc, char **argv)
{
	int op, ret;

	opts = INIT_OPTS;
	hints = fi_allocinfo();
	if (!hints)
		return EXIT_FAILURE;

	while ((op = getopt(argc, argv, "h" ADDR_OPTS INFO_OPTS)) != -1) {
		switch (op) {
		default:
			ft_parse_addr_opts(op, optarg, &opts);
			ft_parseinfo(op, optarg, hints);
			break;
		case '?':
		case 'h':
			ft_usage(argv[0], "A simple MSG client-sever example that "
				"demonstrates one possible usage of the underlying "
				"cq wait objects.");
			return EXIT_FAILURE;
		}
	}

	if (optind < argc)
		opts.dst_addr = argv[optind];

	hints->ep_attr->type	= FI_EP_MSG;
	hints->caps		= FI_MSG;
	hints->mode		= FI_LOCAL_MR;
	hints->addr_format	= FI_SOCKADDR;

	/* Fabric and connection setup */
	if (!opts.dst_addr) {
		ret = server_listen();
		if (ret)
			return -ret;
	}

	ret = opts.dst_addr ? client_connect() : server_connect();
	if (ret) {
		return -ret;
	}

	/* Exchange data */
	ret = send_recv();

	fi_shutdown(ep, 0);
	free_ep_res();
	fi_close(&cmeq->fid);
	fi_close(&dom->fid);
	fi_close(&fab->fid);

	return ret;
}
开发者ID:jsquyres,项目名称:fabtests,代码行数:55,代码来源:msg_epoll.c


示例18: server_init_process

/***********************************************************************
 *           server_init_process
 *
 * Start the server and create the initial socket pair.
 */
void server_init_process(void)
{
    obj_handle_t version;
    const char *env_socket = getenv( "WINESERVERSOCKET" );

    server_pid = -1;
    if (env_socket)
    {
        fd_socket = atoi( env_socket );
        if (fcntl( fd_socket, F_SETFD, 1 ) == -1)
            fatal_perror( "Bad server socket %d", fd_socket );
        unsetenv( "WINESERVERSOCKET" );
    }
    else fd_socket = server_connect();

    /* setup the signal mask */
    sigemptyset( &server_block_set );
    sigaddset( &server_block_set, SIGALRM );
    sigaddset( &server_block_set, SIGIO );
    sigaddset( &server_block_set, SIGINT );
    sigaddset( &server_block_set, SIGHUP );
    sigaddset( &server_block_set, SIGUSR1 );
    sigaddset( &server_block_set, SIGUSR2 );
    sigaddset( &server_block_set, SIGCHLD );
    pthread_sigmask( SIG_BLOCK, &server_block_set, NULL );

    /* receive the first thread request fd on the main socket */
#ifdef SO_PASSCRED
    if (server_pid == -1)
    {
        int enable = 1;
        setsockopt( fd_socket, SOL_SOCKET, SO_PASSCRED, &enable, sizeof(enable) );
        ntdll_get_thread_data()->request_fd = receive_fd( &version );
        enable = 0;
        setsockopt( fd_socket, SOL_SOCKET, SO_PASSCRED, &enable, sizeof(enable) );
    }
    else
#endif
    ntdll_get_thread_data()->request_fd = receive_fd( &version );

    if (version != SERVER_PROTOCOL_VERSION)
        server_protocol_error( "version mismatch %d/%d.\n"
                               "Your %s binary was not upgraded correctly,\n"
                               "or you have an older one somewhere in your PATH.\n"
                               "Or maybe the wrong wineserver is still running?\n",
                               version, SERVER_PROTOCOL_VERSION,
                               (version > SERVER_PROTOCOL_VERSION) ? "wine" : "wineserver" );
#ifdef __APPLE__
    send_server_task_port();
#endif
#if defined(__linux__) && defined(HAVE_PRCTL)
    /* work around Ubuntu's ptrace breakage */
    if (server_pid != -1) prctl( 0x59616d61 /* PR_SET_PTRACER */, server_pid );
#endif
}
开发者ID:dvdhoo,项目名称:wine,代码行数:60,代码来源:server.c


示例19: main

int main(int argc, char *argv[])
{
  if(argc < 2 || argc > 4)
  {
    printf("\n Usage: %s port [a|b] [name] \n",argv[0]);
    return 1;
  } 
  sockfd = server_connect(argv[1]);
  if (sockfd < 0) {
    // something happened while trying to connect-- abort mission
    return -1;
  }
  
  parse_settings(argv[2], argv[3]);


  printf("Request name %s and team %d\n", name, team);

  //construct proper sendBuff
  //(name, team)
  snprintf(sendBuff, sizeof sendBuff, "%s %d", name, team);

  // send it
  send_to_server();
  // read reply
  read_from_server();

  //printf("Bytes written: %d. Bytes read: %d.\n%s\n", writtenbytes, readbytes, recvBuff);
  sscanf(recvBuff, "%s", recvName);
  printf("%s\n", recvBuff);
  char *ghs = "Game has already started";
  if(strcmp(ghs, recvBuff) == 0){
    close(sockfd);
    return 0;
  }

  initscr();
  loading_screen();
  display_teams();
  start_color();
  initscr();
  loadMap(mapNameFromServer);
  teamInfoMap();
  initBoard();/* creates play board */
  refresh();/* Print it on to the real screen */
  load_players();
  //place_players();
  control_test();
  final_standings();
  getch();
  endwin();

  close(sockfd);
  return 0;
}
开发者ID:LilongHuang,项目名称:TowerDefense,代码行数:55,代码来源:client.c


示例20: main

int		main(int ac, char **av)
{
	t_env	env;

	if (ac < 3)
		ft_exit("client: invalid arguments\nclient <host> <port>"
				, EXIT_FAILURE);
	parse_arguments(&env, av);
	resolve_host(&env);
	server_connect(&env);
	run(&env);
}
开发者ID:acazuc,项目名称:42_ft_p,代码行数:12,代码来源:main.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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