int main(int argc, char *argv[]) { SVCXPRT *transp; int sock = 0; int proto = 0; struct sockaddr_in from; int fromlen; if (argc == 2) closedown = atoi(argv[1]); if (closedown <= 0) closedown = 20; /* * See if inetd started us */ fromlen = sizeof(from); if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) { from_inetd = 0; sock = RPC_ANYSOCK; proto = IPPROTO_UDP; } if (!from_inetd) { daemon(0, 0); (void)pmap_unset(RSTATPROG, RSTATVERS_TIME); (void)pmap_unset(RSTATPROG, RSTATVERS_SWTCH); (void)pmap_unset(RSTATPROG, RSTATVERS_ORIG); (void) signal(SIGINT, cleanup); (void) signal(SIGTERM, cleanup); (void) signal(SIGHUP, cleanup); } openlog("rpc.rstatd", LOG_CONS|LOG_PID, LOG_DAEMON); transp = svcudp_create(sock); if (transp == NULL) { syslog(LOG_ERR, "cannot create udp service"); exit(1); } if (!svc_register(transp, RSTATPROG, RSTATVERS_TIME, rstat_service, proto)) { syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_TIME, %s)", proto?"udp":"(inetd)"); exit(1); } if (!svc_register(transp, RSTATPROG, RSTATVERS_SWTCH, rstat_service, proto)) { syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_SWTCH, %s)", proto?"udp":"(inetd)"); exit(1); } if (!svc_register(transp, RSTATPROG, RSTATVERS_ORIG, rstat_service, proto)) { syslog(LOG_ERR, "unable to register (RSTATPROG, RSTATVERS_ORIG, %s)", proto?"udp":"(inetd)"); exit(1); } svc_run(); syslog(LOG_ERR, "svc_run returned"); exit(1); }
int main(int argc, char **argv) { register SVCXPRT *transp; signal(SIGCHLD, sigchld); (void) pmap_unset(SCSI_PROG, SCSI_VERS); transp = svcudp_create(RPC_ANYSOCK); if (transp == NULL) { fprintf(stderr, "cannot create udp service."); exit(1); } if (!svc_register(transp, SCSI_PROG, SCSI_VERS, scsi_prog_1, IPPROTO_UDP)) { fprintf(stderr, "unable to register (SCSI_PROG, SCSI_VERS, udp)."); exit(1); } transp = svctcp_create(RPC_ANYSOCK, 0, 0); if (transp == NULL) { fprintf(stderr, "cannot create tcp service."); exit(1); } if (!svc_register(transp, SCSI_PROG, SCSI_VERS, scsi_prog_1, IPPROTO_TCP)) { fprintf(stderr, "unable to register (SCSI_PROG, SCSI_VERS, tcp)."); exit(1); } svc_run(); fprintf(stderr, "svc_run returned"); exit(1); /* NOTREACHED */ }
int main(int argn, char *argc[]) { //Server parameter is : argc[1] : Server Program Number // others arguments depend on server program int run_mode = 0; int progNum = atoi(argc[1]); char *simplePing_proc(); bool_t rslt; char nettype[16] = "visible"; if (run_mode) { printf("Prog Num : %d\n", progNum); } svc_unreg(progNum, VERSNUM); rslt = rpc_reg(progNum, VERSNUM, PROCSIMPLEPING, (void *)simplePing_proc, (xdrproc_t)xdr_int, (xdrproc_t)xdr_int, nettype); svc_run(); fprintf(stderr, "svc_run() returned. ERROR has occurred.\n"); svc_unreg(progNum, VERSNUM); return 1; }
int main(int argc, char *argv[]) { SVCXPRT *transp; socklen_t salen; int ok; struct sockaddr_storage sa; if (argc == 2 && !strcmp(argv[1], "-n")) nodaemon = 1; if (argc != 1 && !nodaemon) usage(); if (geteuid() == 0) { struct passwd *pep = getpwnam("nobody"); if (pep) setuid(pep->pw_uid); else setuid(getuid()); } /* * See if inetd started us */ salen = sizeof(sa); if (getsockname(0, (struct sockaddr *)&sa, &salen) < 0) { from_inetd = 0; } if (!from_inetd) { if (!nodaemon) possess(); (void)rpcb_unset(WALLPROG, WALLVERS, NULL); } (void)signal(SIGCHLD, killkids); openlog("rpc.rwalld", LOG_CONS|LOG_PID, LOG_DAEMON); /* create and register the service */ if (from_inetd) { transp = svc_tli_create(0, NULL, NULL, 0, 0); if (transp == NULL) { syslog(LOG_ERR, "couldn't create udp service."); exit(1); } ok = svc_reg(transp, WALLPROG, WALLVERS, wallprog_1, NULL); } else ok = svc_create(wallprog_1, WALLPROG, WALLVERS, "udp"); if (!ok) { syslog(LOG_ERR, "unable to register (WALLPROG, WALLVERS, %s)", (!from_inetd)?"udp":"(inetd)"); exit(1); } svc_run(); syslog(LOG_ERR, "svc_run returned"); exit(1); }
//****************************************// //*** Main Function ***// //****************************************// int main(int argn, char *argc[]) { int progNum = atoi(argc[1]); SVCXPRT *transp; struct netconfig *nconf; if ((nconf = getnetconfigent("udp")) == NULL) { fprintf(stderr, "Cannot get netconfig entry for UDP\n"); exit(1); } transp = svc_tp_create(exm_proc, progNum, VERSNUM, nconf); if (transp == NULL) { fprintf(stderr, "Cannot create service.\n"); exit(1); } svc_run(); fprintf(stderr, "svc_run() returned. ERROR has occurred.\n"); svc_unreg(progNum, VERSNUM); return 1; }
int main (int argc, char **argv) { register SVCXPRT *transp; pmap_unset (WHATSUPPROG, WHATSUPVERS); transp = svcudp_create(RPC_ANYSOCK); if (transp == NULL) { fprintf (stderr, "%s", "cannot create udp service."); exit(1); } if (!svc_register(transp, WHATSUPPROG, WHATSUPVERS, whatsupprog_1, IPPROTO_UDP)) { fprintf (stderr, "%s", "unable to register (WHATSUPPROG, WHATSUPVERS, udp)."); exit(1); } transp = svctcp_create(RPC_ANYSOCK, 0, 0); if (transp == NULL) { fprintf (stderr, "%s", "cannot create tcp service."); exit(1); } if (!svc_register(transp, WHATSUPPROG, WHATSUPVERS, whatsupprog_1, IPPROTO_TCP)) { fprintf (stderr, "%s", "unable to register (WHATSUPPROG, WHATSUPVERS, tcp)."); exit(1); } svc_run (); fprintf (stderr, "%s", "svc_run returned"); exit (1); /* NOTREACHED */ }
int main (int argc, char **argv) { register SVCXPRT *transp; pmap_unset (COOKIE_JAR, COOKIE_JAR_VERSION); transp = svcudp_create(RPC_ANYSOCK); if (transp == NULL) { fprintf (stderr, "%s", "cannot create udp service."); exit(1); } if (!svc_register(transp, COOKIE_JAR, COOKIE_JAR_VERSION, cookie_jar_1, IPPROTO_UDP)) { fprintf (stderr, "%s", "unable to register (COOKIE_JAR, COOKIE_JAR_VERSION, udp)."); exit(1); } transp = svctcp_create(RPC_ANYSOCK, 0, 0); if (transp == NULL) { fprintf (stderr, "%s", "cannot create tcp service."); exit(1); } if (!svc_register(transp, COOKIE_JAR, COOKIE_JAR_VERSION, cookie_jar_1, IPPROTO_TCP)) { fprintf (stderr, "%s", "unable to register (COOKIE_JAR, COOKIE_JAR_VERSION, tcp)."); exit(1); } svc_run (); fprintf (stderr, "%s", "svc_run returned"); exit (1); /* NOTREACHED */ }
void * rpc2_server() { register SVCXPRT *transp; pmap_unset (RPC2_RPC_PROG, RPC2_RPC_VERS1); transp = svcudp_create(RPC_ANYSOCK); if (transp == NULL) { fprintf (stderr, "%s", "cannot create udp service."); exit(1); } if (!svc_register(transp, RPC2_RPC_PROG, RPC2_RPC_VERS1, rpc2_rpc_prog_1, IPPROTO_UDP)) { fprintf (stderr, "%s", "unable to register (RPC2_RPC_PROG, RPC2_RPC_VERS1, udp)."); exit(1); } transp = svctcp_create(RPC_ANYSOCK, 0, 0); if (transp == NULL) { fprintf (stderr, "%s", "cannot create tcp service."); exit(1); } if (!svc_register(transp, RPC2_RPC_PROG, RPC2_RPC_VERS1, rpc2_rpc_prog_1, IPPROTO_TCP)) { fprintf (stderr, "%s", "unable to register (RPC2_RPC_PROG, RPC2_RPC_VERS1, tcp)."); exit(1); } svc_run (); fprintf (stderr, "%s", "svc_run returned"); exit (1); /* NOTREACHED */ }
int main (int argc, char **argv) { register SVCXPRT *transp; pmap_unset (NAMENODE, NN); transp = svcudp_create(RPC_ANYSOCK); if (transp == NULL) { fprintf (stderr, "%s", "cannot create udp service."); exit(1); } if (!svc_register(transp, NAMENODE, NN, namenode_1, IPPROTO_UDP)) { fprintf (stderr, "%s", "unable to register (NAMENODE, NN, udp)."); exit(1); } transp = svctcp_create(RPC_ANYSOCK, 0, 0); if (transp == NULL) { fprintf (stderr, "%s", "cannot create tcp service."); exit(1); } if (!svc_register(transp, NAMENODE, NN, namenode_1, IPPROTO_TCP)) { fprintf (stderr, "%s", "unable to register (NAMENODE, NN, tcp)."); exit(1); } svc_run (); fprintf (stderr, "%s", "svc_run returned"); exit (1); /* NOTREACHED */ }
void *server_thread_process(void *arg) { //Server process in a thread int err = 0; if (run_mode == 1) { printf("Server #%d launched\n", atoi(arg)); printf("Server Nb : %d\n", progNum + atoi(arg)); } svc_unreg(progNum + (long)arg, VERSNUM); err = svc_create(exm_proc, progNum + atoi(arg), VERSNUM, "VISIBLE"); if (err == 0) { fprintf(stderr, "Cannot create service.\n"); exit(1); } svc_run(); fprintf(stderr, "svc_run() returned. ERROR has occurred.\n"); svc_unreg(progNum, VERSNUM); pthread_exit(0); }
int main (int argc, char **argv) { thread_opts_t opts; opts.udp_port = 51234; opts.tcp_port = 51234; opts.sock = create_mcast_sock(NULL, opts.udp_port); pthread_t mcast_thread, tcp_thread; pthread_create(&mcast_thread, NULL, start_mcast_thread, &opts); pthread_create(&tcp_thread, NULL, start_tcp_thread, &opts); register SVCXPRT *transp; pmap_unset (OCL_PROG, OCL_VERS); transp = svctcp_create(RPC_ANYSOCK, 0, 0); if (transp == NULL) { fprintf (stderr, "%s", "cannot create tcp service."); exit(1); } if (!svc_register(transp, OCL_PROG, OCL_VERS, ocl_prog_1, IPPROTO_TCP)) { fprintf (stderr, "%s", "unable to register (OCL_PROG, OCL_VERS, tcp)."); exit(1); } svc_run (); fprintf (stderr, "%s", "svc_run returned"); exit (1); /* NOTREACHED */ }
main() { SVCXPRT *transp; (void)pmap_unset(KUNDENPROG, KUNDENVERS); transp = svcudp_create(RPC_ANYSOCK); if (transp == NULL) { (void)fprintf(stderr, "cannot create udp service.\n"); exit(1); } if (!svc_register(transp, KUNDENPROG, KUNDENVERS, kundenprog_1, IPPROTO_UDP)) { (void)fprintf(stderr, "unable to register (KUNDENPROG, KUNDENVERS, udp).\n"); exit(1); } transp = svctcp_create(RPC_ANYSOCK, 0, 0); if (transp == NULL) { (void)fprintf(stderr, "cannot create tcp service.\n"); exit(1); } if (!svc_register(transp, KUNDENPROG, KUNDENVERS, kundenprog_1, IPPROTO_TCP)) { (void)fprintf(stderr, "unable to register (KUNDENPROG, KUNDENVERS, tcp).\n"); exit(1); } svc_run(); (void)fprintf(stderr, "svc_run returned\n"); exit(1); }
int main (int argc, char **argv) { register SVCXPRT *transp; pmap_unset (DISPLAY_PRG, DISPLAY_VER); transp = svcudp_create(RPC_ANYSOCK); if (transp == NULL) { fprintf (stderr, "%s", "cannot create udp service."); exit(1); } if (!svc_register(transp, DISPLAY_PRG, DISPLAY_VER, display_prg_1, IPPROTO_UDP)) { fprintf (stderr, "%s", "unable to register (DISPLAY_PRG, DISPLAY_VER, udp)."); exit(1); } transp = svctcp_create(RPC_ANYSOCK, 0, 0); if (transp == NULL) { fprintf (stderr, "%s", "cannot create tcp service."); exit(1); } if (!svc_register(transp, DISPLAY_PRG, DISPLAY_VER, display_prg_1, IPPROTO_TCP)) { fprintf (stderr, "%s", "unable to register (DISPLAY_PRG, DISPLAY_VER, tcp)."); exit(1); } svc_run (); fprintf (stderr, "%s", "svc_run returned"); exit (1); /* NOTREACHED */ }
void * mount3udp_thread (void *argv) { xlator_t *nfsx = argv; register SVCXPRT *transp = NULL; GF_ASSERT (nfsx); if (glusterfs_this_set(nfsx)) { gf_log (GF_MNT, GF_LOG_ERROR, "failed to set xlator, " "nfs.mount-udp will not work"); return NULL; } transp = svcudp_create(RPC_ANYSOCK); if (transp == NULL) { gf_log (GF_MNT, GF_LOG_ERROR, "svcudp_create error"); return NULL; } if (!svc_register(transp, MOUNT_PROGRAM, MOUNT_V3, mountudp_program_3, IPPROTO_UDP)) { gf_log (GF_MNT, GF_LOG_ERROR, "svc_register error"); return NULL; } svc_run (); gf_log (GF_MNT, GF_LOG_ERROR, "svc_run returned"); return NULL; }
//****************************************// //*** Main Function ***// //****************************************// int main(int argn, char *argc[]) { //Server parameter is : argc[1] : Server Program Number // others arguments depend on server program int progNum = atoi(argc[1]); SVCXPRT *transp = NULL; struct netconfig *nconf; //Initialization svc_unreg(progNum, VERSNUM); if ((nconf = getnetconfigent("udp")) == NULL) { fprintf(stderr, "Cannot get netconfig entry for UDP\n"); exit(1); } transp = svc_tp_create(exm_proc, progNum, VERSNUM, nconf); if (transp == NULL) { fprintf(stderr, "Cannot create service.\n"); exit(1); } if (!svc_reg(transp, progNum, VERSNUM, exm_proc, nconf)) { fprintf(stderr, "svc_reg failed!!\n"); exit(1); } svc_run(); fprintf(stderr, "svc_run() returned. ERROR has occurred.\n"); svc_unreg(progNum, VERSNUM); return 1; }
int main (int argc, char **argv) { register SVCXPRT *transp; pmap_unset (ARRAYSUM_CALC, ARRAYSUM_CALC_1); transp = svcudp_create(RPC_ANYSOCK); if (transp == NULL) { fprintf (stderr, "%s", "cannot create udp service."); exit(1); } if (!svc_register(transp, ARRAYSUM_CALC, ARRAYSUM_CALC_1, arraysum_calc_1, IPPROTO_UDP)) { fprintf (stderr, "%s", "unable to register (ARRAYSUM_CALC, ARRAYSUM_CALC_1, udp)."); exit(1); } transp = svctcp_create(RPC_ANYSOCK, 0, 0); if (transp == NULL) { fprintf (stderr, "%s", "cannot create tcp service."); exit(1); } if (!svc_register(transp, ARRAYSUM_CALC, ARRAYSUM_CALC_1, arraysum_calc_1, IPPROTO_TCP)) { fprintf (stderr, "%s", "unable to register (ARRAYSUM_CALC, ARRAYSUM_CALC_1, tcp)."); exit(1); } svc_run (); fprintf (stderr, "%s", "svc_run returned"); exit (1); /* NOTREACHED */ }
//****************************************// //*** Main Function ***// //****************************************// int main(int argn, char *argc[]) { //Server parameter is : argc[1] : Server Program Number // others arguments depend on server program int run_mode = 0; int progNum = atoi(argc[1]); //char *simplePing_proc(); bool_t rslt; //char nettype[16] = "visible"; SVCXPRT *transp; struct netconfig *nconf; if ((nconf = getnetconfigent("udp")) == NULL) { fprintf(stderr, "Cannot get netconfig entry for UDP\n"); exit(1); } transp = svc_tp_create(exm_proc, progNum, VERSNUM, nconf); if (transp == NULL) { fprintf(stderr, "Cannot create service.\n"); exit(1); } svc_run(); fprintf(stderr, "svc_run() returned. ERROR has occurred.\n"); svc_unreg(progNum, VERSNUM); return 1; }
/* * Called by nfssvc() for nfsds. Just loops around servicing rpc requests * until it is killed by a signal. */ int nfsrvd_nfsd(struct thread *td, struct nfsd_nfsd_args *args) { char principal[MAXHOSTNAMELEN + 5]; int error = 0; bool_t ret2, ret3, ret4; error = copyinstr(args->principal, principal, sizeof (principal), NULL); if (error) goto out; /* * Only the first nfsd actually does any work. The RPC code * adds threads to it as needed. Any extra processes offered * by nfsd just exit. If nfsd is new enough, it will call us * once with a structure that specifies how many threads to * use. */ NFSD_LOCK(); if (newnfs_numnfsd == 0) { newnfs_numnfsd++; NFSD_UNLOCK(); /* An empty string implies AUTH_SYS only. */ if (principal[0] != '\0') { ret2 = rpc_gss_set_svc_name_call(principal, "kerberosv5", GSS_C_INDEFINITE, NFS_PROG, NFS_VER2); ret3 = rpc_gss_set_svc_name_call(principal, "kerberosv5", GSS_C_INDEFINITE, NFS_PROG, NFS_VER3); ret4 = rpc_gss_set_svc_name_call(principal, "kerberosv5", GSS_C_INDEFINITE, NFS_PROG, NFS_VER4); if (!ret2 || !ret3 || !ret4) printf("nfsd: can't register svc name\n"); } nfsrvd_pool->sp_minthreads = args->minthreads; nfsrvd_pool->sp_maxthreads = args->maxthreads; svc_run(nfsrvd_pool); if (principal[0] != '\0') { rpc_gss_clear_svc_name_call(NFS_PROG, NFS_VER2); rpc_gss_clear_svc_name_call(NFS_PROG, NFS_VER3); rpc_gss_clear_svc_name_call(NFS_PROG, NFS_VER4); } NFSD_LOCK(); newnfs_numnfsd--; nfsrvd_init(1); } NFSD_UNLOCK(); out: NFSEXITCODE(error); return (error); }
int main (int argc, char **argv) { register SVCXPRT *transp; pmap_unset (TELL_ME_DAY1, TELL_ME_DAY_VERSION1); pmap_unset (TELL_ME_DAY2, TELL_ME_DAY_VERSION2); pmap_unset (TELL_ME_DAY3, TELL_ME_DAY_VERSION3); pmap_unset (TELL_ME_DAY4, TELL_ME_DAY_VERSION4); transp = svcudp_create(RPC_ANYSOCK); if (transp == NULL) { fprintf (stderr, "%s", "cannot create udp service."); exit(1); } if (!svc_register(transp, TELL_ME_DAY1, TELL_ME_DAY_VERSION1, tell_me_day1_1, IPPROTO_UDP)) { fprintf (stderr, "%s", "unable to register (TELL_ME_DAY1, TELL_ME_DAY_VERSION1, udp)."); exit(1); } if (!svc_register(transp, TELL_ME_DAY2, TELL_ME_DAY_VERSION2, tell_me_day2_2, IPPROTO_UDP)) { fprintf (stderr, "%s", "unable to register (TELL_ME_DAY2, TELL_ME_DAY_VERSION2, udp)."); exit(1); } if (!svc_register(transp, TELL_ME_DAY3, TELL_ME_DAY_VERSION3, tell_me_day3_3, IPPROTO_UDP)) { fprintf (stderr, "%s", "unable to register (TELL_ME_DAY3, TELL_ME_DAY_VERSION3, udp)."); exit(1); } if (!svc_register(transp, TELL_ME_DAY4, TELL_ME_DAY_VERSION4, tell_me_day4_4, IPPROTO_UDP)) { fprintf (stderr, "%s", "unable to register (TELL_ME_DAY4, TELL_ME_DAY_VERSION4, udp)."); exit(1); } transp = svctcp_create(RPC_ANYSOCK, 0, 0); if (transp == NULL) { fprintf (stderr, "%s", "cannot create tcp service."); exit(1); } if (!svc_register(transp, TELL_ME_DAY1, TELL_ME_DAY_VERSION1, tell_me_day1_1, IPPROTO_TCP)) { fprintf (stderr, "%s", "unable to register (TELL_ME_DAY1, TELL_ME_DAY_VERSION1, tcp)."); exit(1); } if (!svc_register(transp, TELL_ME_DAY2, TELL_ME_DAY_VERSION2, tell_me_day2_2, IPPROTO_TCP)) { fprintf (stderr, "%s", "unable to register (TELL_ME_DAY2, TELL_ME_DAY_VERSION2, tcp)."); exit(1); } if (!svc_register(transp, TELL_ME_DAY3, TELL_ME_DAY_VERSION3, tell_me_day3_3, IPPROTO_TCP)) { fprintf (stderr, "%s", "unable to register (TELL_ME_DAY3, TELL_ME_DAY_VERSION3, tcp)."); exit(1); } if (!svc_register(transp, TELL_ME_DAY4, TELL_ME_DAY_VERSION4, tell_me_day4_4, IPPROTO_TCP)) { fprintf (stderr, "%s", "unable to register (TELL_ME_DAY4, TELL_ME_DAY_VERSION4, tcp)."); exit(1); } svc_run (); fprintf (stderr, "%s", "svc_run returned"); exit (1); /* NOTREACHED */ }
int main (void) { bool_t stat; stat = registerrpc(PROGNUM,VERSNUM,PROCNUM,divise,(xdrproc_t)xdr_entiers2,(xdrproc_t)xdr_entiers2); if (stat != 0) { fprintf(stderr,"Echec de l'enregistrement\n"); exit(1); } svc_run(); /* le serveur est en attente de clients eventuels */ return(0); /* on y passe jamais ! */ }
main() { int ival; sigset_t qmask; struct sigaction sigchld_vec; SVCXPRT *transp; sigemptyset( &qmask ); sigchld_vec.sa_handler = (void *) sigchld_irpt; sigchld_vec.sa_mask = qmask; sigchld_vec.sa_flags = 0; ival = sigaction( SIGCHLD, &sigchld_vec, 0 ); if (ival < 0) { perror( "sigaction failed for SIGCHLD" ); exit( 10 ); } /* * Unregister our server before registering it again. This makes sure we * clear out any old versions */ (void) pmap_unset(ACQINFOPROG, ACQINFOVERS); /* Create a TCP socket for the server */ transp = svctcp_create(RPC_ANYSOCK, 0, 0); if (transp == NULL) { (void) fprintf(stderr, "cannot create tcp service.\n"); exit(1); } /* * Register the server with the portmapper so that clients can find out * what our port number is */ if (!svc_register(transp, ACQINFOPROG, ACQINFOVERS, acqinfoprog_2, IPPROTO_TCP)) { (void) fprintf(stderr, "unable to register (ACQINFOPROG, ACQINFOVERS, tcp).\n"); exit(1); } /* * The portmapper table now has a program number, version, and protocol, * associated with a port number for our server. Now go to sleep until a * request comes in for this server. */ svc_run(); (void) fprintf(stderr, "svc_run returned\n"); exit(1); }
static void daemon_simulator (void) { signal (SIGHUP, sim_killer); signal (SIGINT, sim_killer); signal (SIGTERM, sim_killer); pmap_unset (sim_port, SIM_SM_VERS); /* this registers both UDP and TCP services */ rpc_init("statd", sim_port, SIM_SM_VERS, sim_sm_prog_1, 0); svc_run (); pmap_unset (sim_port, SIM_SM_VERS); }
int main(void) { SVCXPRT *xprt; xprt = svctcp_create(RPC_ANYSOCK, 0, 0); if (xprt == NULL) errx(2, "svctcp_create\n"); pmap_unset(RUSERSPROG, RUSERSVERS); if (!svc_register(xprt, RUSERSPROG, RUSERSVERS, dispatch, IPPROTO_TCP)) errx(1, "svc_register\n"); svc_run(); return 0; }
int main () { bool_t xdr_rls(); char *do_rls(); int a; while(1) { printf("%d\n" ,a); usleep(10); } registerrpc(RLS_PROG, RLS_VER, RLS_PROC, do_rls, xdr_rls, xdr_rls); svc_run(); }
int main (int argc, char **argv) { try { if(argc<2) { throw GenericError("Faltan parametros para torre_de_control_svc: ./torre_de_control_svc config_file_abs_path"); } std::string wkdir = ApiConfiguracion::get_torre_wkdir(argv[1]); crear_archivos_lck_torre(wkdir.c_str()); torre_de_control = new TorreDeControlSvc(wkdir.c_str()); api_torre = new ApiTorreDeControlSvc(wkdir.c_str(), argv[1]); register SVCXPRT *transp; pmap_unset (TORREDECONTROLPROG, TORREDECONTROLVERS); transp = svcudp_create(RPC_ANYSOCK); if (transp == NULL) { fprintf (stderr, "%s", "cannot create udp service."); exit(1); } if (!svc_register(transp, TORREDECONTROLPROG, TORREDECONTROLVERS, torredecontrolprog_1, IPPROTO_UDP)) { fprintf (stderr, "%s", "unable to register (TORREDECONTROLPROG, TORREDECONTROLVERS, udp)."); exit(1); } transp = svctcp_create(RPC_ANYSOCK, 0, 0); if (transp == NULL) { fprintf (stderr, "%s", "cannot create tcp service."); exit(1); } if (!svc_register(transp, TORREDECONTROLPROG, TORREDECONTROLVERS, torredecontrolprog_1, IPPROTO_TCP)) { fprintf (stderr, "%s", "unable to register (TORREDECONTROLPROG, TORREDECONTROLVERS, tcp)."); exit(1); } svc_run (); fprintf (stderr, "%s", "svc_run returned"); return(0); // exit (1); /* NOTREACHED */ } catch (const std::exception &e) { Log::crit("%s", e.what()); } catch (...) { Log::crit("Critical error. Unknow exception at the end of the 'main' function."); } }
int main(int argc, char *argv[]) { SVCXPRT *transp; int ok; struct sockaddr_storage from; socklen_t fromlen; /* * See if inetd started us */ fromlen = sizeof(from); if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) { from_inetd = 0; } if (!from_inetd) { daemon(0, 0); (void) rpcb_unset(SPRAYPROG, SPRAYVERS, NULL); (void) signal(SIGINT, cleanup); (void) signal(SIGTERM, cleanup); (void) signal(SIGHUP, cleanup); } else { (void) signal(SIGALRM, die); alarm(TIMEOUT); } openlog("rpc.sprayd", LOG_CONS|LOG_PID, LOG_DAEMON); if (from_inetd) { transp = svc_tli_create(0, NULL, NULL, 0, 0); if (transp == NULL) { syslog(LOG_ERR, "cannot create udp service."); exit(1); } ok = svc_reg(transp, SPRAYPROG, SPRAYVERS, spray_service, NULL); } else ok = svc_create(spray_service, SPRAYPROG, SPRAYVERS, "udp"); if (!ok) { syslog(LOG_ERR, "unable to register (SPRAYPROG, SPRAYVERS, %s)", (!from_inetd)?"udp":"(inetd)"); return 1; } svc_run(); syslog(LOG_ERR, "svc_run returned"); return 1; }
int main (void) { registerrpc(/* prognum */ PROGNUM, /* versnum */ VERSNUM, /* procnum */ PROCNUM, /* pointer on function */ proc_dist, /* argument decoding */ (xdrproc_t)xdr_int, /* function result encoding */ (xdrproc_t)xdr_int) ; svc_run() ; /* server ready for clients */ return 0 ; }
/*-------------------------------------------------------------------*/ int main(void){ Print (("start B\n")); /*rejestracja funkcji wywolywanych zdalnie */ assert (registerrpc(PROGNUM, VERSNUM, SENDNUM, (char*(*)())get_string, (int(*)())xdr_napis, (int(*)())xdr_void) == 0); assert (registerrpc(PROGNUM, VERSNUM, RECVNUM, (char*(*)())ret, (int(*)())xdr_void, (int(*)())xdr_napis) == 0); /*przejscie procesu w stan oczekiwania*/ Print (("Start svc\n")); svc_run(); return 0; }
int main(int argc, char *argv[]) { SVCXPRT *transp; int sock = 0; int proto = 0; struct sockaddr_in from; int fromlen; /* * See if inetd started us */ fromlen = sizeof(from); if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) { from_inetd = 0; sock = RPC_ANYSOCK; proto = IPPROTO_UDP; } if (!from_inetd) { daemon(0, 0); (void) pmap_unset(SPRAYPROG, SPRAYVERS); (void) signal(SIGINT, cleanup); (void) signal(SIGTERM, cleanup); (void) signal(SIGHUP, cleanup); } else { (void) signal(SIGALRM, die); alarm(TIMEOUT); } openlog("rpc.sprayd", LOG_CONS|LOG_PID, LOG_DAEMON); transp = svcudp_create(sock); if (transp == NULL) { syslog(LOG_ERR, "cannot create udp service"); return 1; } if (!svc_register(transp, SPRAYPROG, SPRAYVERS, spray_service, proto)) { syslog(LOG_ERR, "unable to register (SPRAYPROG, SPRAYVERS, %s)", proto ? "udp" : "(inetd)"); return 1; } svc_run(); syslog(LOG_ERR, "svc_run returned"); return 1; }
int main (int argc, char **argv) { register SVCXPRT *transp; pmap_unset (DEVICE_ASYNC, DEVICE_ASYNC_VERSION); pmap_unset (DEVICE_CORE, DEVICE_CORE_VERSION); pmap_unset (DEVICE_INTR, DEVICE_INTR_VERSION); transp = svcudp_create(RPC_ANYSOCK); if (transp == NULL) { fprintf (stderr, "%s", "cannot create udp service."); exit(1); } if (!svc_register(transp, DEVICE_ASYNC, DEVICE_ASYNC_VERSION, device_async_1, IPPROTO_UDP)) { fprintf (stderr, "%s", "unable to register (DEVICE_ASYNC, DEVICE_ASYNC_VERSION, udp)."); exit(1); } if (!svc_register(transp, DEVICE_CORE, DEVICE_CORE_VERSION, device_core_1, IPPROTO_UDP)) { fprintf (stderr, "%s", "unable to register (DEVICE_CORE, DEVICE_CORE_VERSION, udp)."); exit(1); } if (!svc_register(transp, DEVICE_INTR, DEVICE_INTR_VERSION, device_intr_1, IPPROTO_UDP)) { fprintf (stderr, "%s", "unable to register (DEVICE_INTR, DEVICE_INTR_VERSION, udp)."); exit(1); } transp = svctcp_create(RPC_ANYSOCK, 0, 0); if (transp == NULL) { fprintf (stderr, "%s", "cannot create tcp service."); exit(1); } if (!svc_register(transp, DEVICE_ASYNC, DEVICE_ASYNC_VERSION, device_async_1, IPPROTO_TCP)) { fprintf (stderr, "%s", "unable to register (DEVICE_ASYNC, DEVICE_ASYNC_VERSION, tcp)."); exit(1); } if (!svc_register(transp, DEVICE_CORE, DEVICE_CORE_VERSION, device_core_1, IPPROTO_TCP)) { fprintf (stderr, "%s", "unable to register (DEVICE_CORE, DEVICE_CORE_VERSION, tcp)."); exit(1); } if (!svc_register(transp, DEVICE_INTR, DEVICE_INTR_VERSION, device_intr_1, IPPROTO_TCP)) { fprintf (stderr, "%s", "unable to register (DEVICE_INTR, DEVICE_INTR_VERSION, tcp)."); exit(1); } svc_run (); fprintf (stderr, "%s", "svc_run returned"); exit (1); /* NOTREACHED */ }