static void server(void) { static unsigned char iptcp[] = "ncacn_ip_tcp"; static unsigned char port[] = PORT; static unsigned char np[] = "ncacn_np"; static unsigned char pipe[] = PIPE; RPC_STATUS status, iptcp_status, np_status; DWORD ret; iptcp_status = RpcServerUseProtseqEp(iptcp, 20, port, NULL); ok(iptcp_status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_ip_tcp) failed with status %d\n", iptcp_status); np_status = RpcServerUseProtseqEp(np, 0, pipe, NULL); if (np_status == RPC_S_PROTSEQ_NOT_SUPPORTED) skip("Protocol sequence ncacn_np is not supported\n"); else ok(np_status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_np) failed with status %d\n", np_status); if (pRpcServerRegisterIfEx) { trace("Using RpcServerRegisterIfEx\n"); status = pRpcServerRegisterIfEx(s_IServer_v0_0_s_ifspec, NULL, NULL, RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH, RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL); } else status = RpcServerRegisterIf(s_IServer_v0_0_s_ifspec, NULL, NULL); ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %d\n", status); status = RpcServerListen(1, 20, TRUE); ok(status == RPC_S_OK, "RpcServerListen failed with status %d\n", status); stop_event = CreateEvent(NULL, FALSE, FALSE, NULL); ok(stop_event != NULL, "CreateEvent failed with error %d\n", GetLastError()); if (iptcp_status == RPC_S_OK) run_client("tcp_basic"); else skip("tcp_basic tests skipped due to earlier failure\n"); if (np_status == RPC_S_OK) run_client("np_basic"); else { skip("np_basic tests skipped due to earlier failure\n"); /* np client is what signals stop_event, so bail out if we didn't run do it */ return; } ret = WaitForSingleObject(stop_event, 1000); ok(WAIT_OBJECT_0 == ret, "WaitForSingleObject\n"); /* if the stop event didn't fire then RpcMgmtWaitServerListen will wait * forever, so don't bother calling it in this case */ if (ret == WAIT_OBJECT_0) { status = RpcMgmtWaitServerListen(); todo_wine { ok(status == RPC_S_OK, "RpcMgmtWaitServerListening failed with status %d\n", status); } }
static ACE_THR_FUNC_RETURN connect_client (void *arg) { u_short *sport = reinterpret_cast <u_short *> (arg); run_client (*sport, client_strategy); return 0; }
int main() { int * pipe_req = pipe_create(); int * pipe_ans = pipe_create(); pid_t fork_res = fork(); switch(fork_res) { case -1: printf("Stopped. Fork error.\n"); break; case 0: close(pipe_req[1]); close(pipe_ans[0]); run_server(pipe_req[0], pipe_ans[1]); close(pipe_req[0]); close(pipe_ans[1]); break; default: close(pipe_req[0]); close(pipe_ans[1]); run_client(pipe_req[1], pipe_ans[0]); close(pipe_req[1]); close(pipe_ans[0]); break; }; pipe_delete(pipe_req); pipe_delete(pipe_ans); return 0; }
int main( int argc, char** argv ) { if ( argc < 4 ) { fprintf( stderr, "must supply a name, server address and port\n" ) ; return 1 ; } uint16_t port ; if( ! parse_port_num( argv[3], & port ) ) { fprintf( stderr, "Must supply valid port number\n" ) ; return 2 ; } /* open a connection to the server */ int fd = connect_client( argv[2], port ) ; SERVER_FD = fd; if ( fd == 0 ) { perror( "Unable to open client" ) ; return 3 ; } /* open a listening socket for peers to connect to */ int peer_sock = peer_socket(); client_t cli ; cli.fd = fd ; cli.peer_fd = peer_sock; start_listener(peer_sock); cli.name = argv[1] ; strncpy(SERVER_NAME, cli.name, 1024); signal(SIGINT, sigint_handler); run_client( & cli ) ; return 0 ; }
int main(int argc, char *argv[]){ int server; int port = DEFAULT_PORT; int c; opterr = 0; while ((c = getopt (argc, argv, "sp:")) != -1){ switch (c){ case 's': server = 1; break; case 'p': port = atoi(optarg); break; default: fprintf(stderr, "undefined argument\n"); exit(1); } } if (server){ run_server(port); } else { run_client(port); } return 0; }
int main_client(std::string QI_UNUSED(src)) { if (valgrind) qi::os::msleep(3000); qi::Session session; qi::Url url = (allInOne && !noGateway)? gateUrl : serverUrl; std::cout <<"Connection to sd... "<< url.str() << std::endl; qi::FutureSync<void> isConnected = session.connect(url); isConnected.wait(3000); if (isConnected.hasError()) { std::cerr << "Can't connect to " << session.url().str() << std::endl; return -1; } std::cout <<"Getting service... " << std::endl; qi::Future<qi::AnyObject> futobj = session.service("serviceTest"); futobj.wait(); qi::AnyObject obj = futobj.value(); std::cerr <<"Done" << std::endl; if (!obj) { std::cerr << "can't get serviceTest " << futobj.error() << std::endl; return -1; } return run_client(obj); }
void fatalrestart(aClient *robotptr, const char *s) { perror(s); close(robotptr->socket); sleep(10); initialize(robotptr); run_client(robotptr); }
int main(int argc, char *argv[]) { set_process_name("ivpn-client"); parse_options(argc, argv); if (geteuid() != 0) { lerr("Effective UID is %u. It need to be 0.", geteuid()); return EXIT_FAILURE; } if (install_sigchld_handler() == 0) return EXIT_FAILURE; if (username == 0) { username = get_current_user(); if (username == 0) exit(EXIT_FAILURE); } if (!sslutil_init(CA_CERT_FILE, 0, 0)) return EXIT_SSL_ERROR; return run_client(); }
int main(int argc, char *argv[]) { //trc_printf("welcome to web agent!\n"); if (argv[1]) run_client(argv[1]); else printf("Usage: %s <message>\n", argv[0]); return 0; }
int main(int argc, char* argv[]) { aClient robot; char *p; if (argc != 6) { fprintf(stderr, "IRCd burst generator, by Carsten V. Munk 2000, based off jupe.c by Nicolas Pioch\n"); fprintf(stderr, "Usage: %s <burstservername> <uplink> <port> <options> <password>\n", argv[0]); fprintf(stderr, "Options can be a combination of these:\n"); fprintf(stderr, "1 = Enable NOQUIT 2 = Enable TOKEN\n"); fprintf(stderr, "3 = Enable NICKv2 4 = Enable SJOIN\n"); fprintf(stderr, "5 = Enable SJOIN2 6 = Enable UMODE2\n"); fprintf(stderr, "7 = Enable NS 8 = Ignore end of burst\n"); fprintf(stderr, "9 = Enable SJ3 a = Enable SJB64\n"); fatal("incorrect argument count"); exit(1); } jupedservername=argv[1]; uplinkservername=argv[2]; jupereason=argv[3]; password = argv[5]; p = argv[4]; for (; *p; p++) { if (*p == '1') options |= 0x1; if (*p == '2') options |= 0x2; if (*p == '3') options |= 0x4; if (*p == '4') options |= 0x8; if (*p == '5') options |= 0x10; if (*p == '6') options |= 0x20; if (*p == '7') options |= 0x40; if (*p == '8') options |= 0x80; if (*p == '9') options |= 0x100; if (*p == 'a') options |= 0x200; } /* installe le signal_catcher */ signal(SIGTERM,(signalhandler)signal_catcher); robot.read=robot.write=0; initialize(&robot); run_client(&robot); exit(0); }
int ACE_TMAIN (int, ACE_TCHAR *argv[]) { // Initialize the logger. ACE_LOG_MSG->open (argv[0]); // Run the client run_client (); return 0; }
int main(int argc, char **argv) { const char *tmp = getenv("TMPDIR"); if (tmp) TMPDIR = tmp; if (argc < 2) return cgi_server(); if (argc < 3) return run_server(atoi(argv[1])); return run_client(argc, argv); }
static void *thread_start(void *arg) { struct thread *t = arg; reset_port(t->ai, atoi(t->opts->port), t->cb); if (t->opts->client) run_client(t); else run_server(t); return NULL; }
int main(int argc, char const* argv[]) { if (argc > 2) { run_client(atoi(argv[1])); } else { run_server(atoi(argv[1])); } return 0; }
pcat_rcode pcat_test_point( pcat_client c, pcat_point p ) { pcat_pt_test_results_ r; printf( ">>> Calling run_client %p\n", p ); run_client( c, p ); printf( "<<< Returned from run_client\n" ); r.quality = 4.2; pcat_map_add( &c->tested_points, p, &r ); return PCAT_SUCCESS; }
/* public functions */ int msntp_set_clock(char *hostname, int port) { int ret; double offset; setup(hostname, port); operation = op_client; if (ret = run_client(&hostname, 1, &offset)) return ret; return adjust_time(offset, 1, 0); }
static void case1(struct zco_context_t *context, int *stage) { pthread_mutex_lock(&port_lock); run_server(context, (ZBindHandler) on_new_client1, last_port, stage); run_client(context, (ZBindHandler) on_client_ready1, last_port, stage); ++last_port; pthread_mutex_unlock(&port_lock); }
int main(int argc, char **argv) { if (argc == 3 && strcmp(argv[1], "-server") == 0) { return run_server((unsigned short) atoi(argv[2])); } else if (argc == 4 && strcmp(argv[1], "-client") == 0) { return run_client(argv[2], (unsigned short) atoi(argv[3])); } printf("Usage: echoz [-server [port] or -client [host] [port]\n"); return 0; }
int main (int argc, char *argv[]) { ACE_UNUSED_ARG(argc); // Initialize the logger. ACE_LOG_MSG->open (argv[0]); // Run the client run_client (); return 0; }
int msntp_get_time(char *hostname, int port, struct timeval *server_time) { int ret; double offset; setup(hostname, port); operation = op_client; if (ret = run_client(&hostname, 1, &offset)) return ret; *server_time = convert_timeval(current_time(offset)); return 0; }
int msntp_get_offset(char *hostname, int port, struct timeval *offset) { int ret; double offset_d; setup(hostname, port); operation = op_client; if (ret = run_client(&hostname, 1, &offset_d)) return ret; *offset = convert_timeval(offset_d); return 0; }
void *client(void *arg) { CLI *c=arg; #ifdef DEBUG_STACK_SIZE stack_info(1); /* initialize */ #endif s_log(LOG_DEBUG, "Service %s started", c->opt->servname); if(c->opt->option.remote && c->opt->option.program) { /* connect and exec options specified together */ /* -> spawn a local program instead of stdio */ while((c->local_rfd.fd=c->local_wfd.fd=connect_local(c))>=0) { run_client(c); if(!c->opt->option.retry) break; sleep(1); /* FIXME: not a good idea in ucontext threading */ str_stats(); str_cleanup(); } } else run_client(c); /* str_free() cannot be used here, because corresponding calloc() is called from a different thread */ free(c); #ifdef DEBUG_STACK_SIZE stack_info(0); /* display computed value */ #endif #ifdef USE_UCONTEXT s_log(LOG_DEBUG, "Context %ld closed", ready_head->id); #endif str_stats(); str_cleanup(); /* s_log() is not allowed after str_cleanup() */ #if defined(USE_WIN32) && !defined(_WIN32_WCE) _endthread(); #endif #ifdef USE_UCONTEXT s_poll_wait(NULL, 0, 0); /* wait on poll() */ #endif return NULL; }
int main() { struct sockaddr sa; unlink(SOCKETNAME); strcpy(sa.sa_data, SOCKETNAME); sa.sa_family = AF_UNIX; for (int client = 1; client <= 4; client++) { assert(run_client(&sa)); } assert(run_server(&sa)); return 0; }
int main( int argc, char *argv[] ) { int size; char filename[100]; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_rank(MPI_COMM_WORLD, &rank); sprintf(filename, "log%d.txt", rank); logfid = fopen(filename,"a"); rankprintf("rank %d of %d\n", rank, size); if (1 == size) { //Run just one degrid // For testing memset(token_list, 0, sizeof(token*)*256); int data[3]; data[0] = TASK_GENVIS; data[1] = 45; data[2] = NPOINTS; exec_task(data); data[0] = TASK_GENIMG; data[1] = 46; data[2] = IMG_SIZE; exec_task(data); data[0] = TASK_DEGRID; data[1] = 45; data[2] = 46; exec_task(data); rankprintf("All tasks complete\n"); return 0; } if (size < 3) { rankprintf("Three processes needed to run this test.\n");fflush(stdout); MPI_Finalize(); return 0; } if (rank == 0) { run_client(size); } else { run_server(size); } fclose(logfid); MPI_Barrier(MPI_COMM_WORLD); MPI_Finalize(); return 0; }
int ndn_rtt(int argc, char **argv) { if (argc < 2) { printf("usage: %s [client|server]\n", argv[0]); return 1; } if (strcmp(argv[1], "client") == 0) { if (argc < 3) { printf("usage: %s client _max_count_\n", argv[0]); return 1; } int max_cnt = atoi(argv[2]); if (max_cnt == 0) { printf("invalid max count number: %s\n", argv[3]); return 1; } run_client(max_cnt); } else if (strcmp(argv[1], "server") == 0) { if (argc < 4) { printf("usage: %s server _sig_type_ _content_size_\n", argv[0]); return 1; } int content_sz = atoi(argv[3]); if (content_sz <= 0 || content_sz > 200) { printf("invalid content size: %s; will set to 4\n", argv[3]); content_sz = 4; } if (strcmp(argv[2], "hmac") == 0) { run_server(NDN_SIG_TYPE_HMAC_SHA256, content_sz); } else if (strcmp(argv[2], "ecdsa") == 0) { run_server(NDN_SIG_TYPE_ECDSA_SHA256, content_sz); } else { printf("unknown signature type: %s\n", argv[2]); return 1; } } else { puts("error: invalid command"); } return 0; }
int main(int argc, char **argv) { if (argc == 1) { printf("Usage: ./conn_sock [-s] [host]\n"); exit(0); } if (strcmp(argv[1], "-s") == 0) run_server(); else run_client(); return 0; }
JNIEXPORT jint JNICALL Java_com_ssb_droidsound_plugins_UADEPlugin_N_1getSoundData(JNIEnv *env, jobject obj, jlong song, jshortArray sArray, jint size) { Player *player = (Player*)song; jshort *dest = env->GetShortArrayElements(sArray, NULL); //__android_log_print(ANDROID_LOG_VERBOSE, "UADEPlugin", "getSoundData"); //if(run_client() < 0) // return 0; soundPtr = dest; int rc = 0; while(rc <= 0) { rc = run_client(); if(rc < 0) { env->ReleaseShortArrayElements(sArray, dest, 0); return -1; } } uade_effect_run(&state.effects, dest, (soundPtr - dest)/2); env->ReleaseShortArrayElements(sArray, dest, 0); return soundPtr - dest; /* int filled = (soundPtr - soundBuffer); int len = size; while(filled < len) { if(run_client() < 0) return 0; filled = (soundPtr - soundBuffer); } memcpy(dest, soundBuffer, len*2); memmove(soundBuffer, soundBuffer+len, (filled-len)*2); soundPtr -= len; env->ReleaseShortArrayElements(sArray, dest, 0); return len; */ }
int main(int argc, char **argv) { int i, start_option, test_mode; if (argc < 2) { printf("mq_test [-d log_level] [-c|-s] [-q]\n"); printf("-c Client mode\n"); printf("-s Server mode\n"); printf("-h Host\n"); printf("**NOTE: Defaults to launching both client and server for internal testing\n"); return(0); } i = 1; do { start_option = i; if (strcmp(argv[i], "-d") == 0) { //** Enable debugging i++; set_log_level(atol(argv[i])); i++; } else if (strcmp(argv[i], "-c") == 0) { //** Client mode i++; test_mode = MODE_CLIENT; } else if (strcmp(argv[i], "-s") == 0) { //** Server mode i++; test_mode = MODE_SERVER; } else if (strcmp(argv[i], "-s") == 0) { //** Server mode i++; host = argv[i]; i++; } } while ((start_option < i) && (i<argc)); apr_wrapper_start(); init_opque_system(); init_random(); if (test_mode == MODE_CLIENT) { run_client(); } else { run_server(); } return(0); }
int main() { signal(SIGINT, signal_handler); pid_t pid = fork(); if (pid < 0) { std::cerr << "Failed to fork" << std::endl; return 1; } else if (pid == 0) { // child code only run_client(); } else { // parent code only run_daemon(); } return 0; }
int main(int ac, char **av) { t_info info; if (ac == 3) { if (init_client(&info, av) && init_socket(&info)) { if (run_client(&info)) return (EXIT_SUCCESS); return (EXIT_FAILURE); } } else print_usage(av[0]); return (EXIT_FAILURE); }