本文整理汇总了C++中server_connect函数的典型用法代码示例。如果您正苦于以下问题:C++ server_connect函数的具体用法?C++ server_connect怎么用?C++ server_connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了server_connect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}