9 #define disable(p) (mask&=~(1<<(sockets[p])))
10 #define enable(p) (mask|= (1<<(sockets[p])))
11 int sockets[MAXPROCS];
12 unsigned int mask=0xffffffff;
19 for(i=0;i<MAXPROCS;i++) sockets[i]=-1;
21 transp = svcudp_create(RPC_ANYSOCK);
23 fprintf(stderr,"could not create an RPC1 server\n");
26 pmap_unset(SRVRPROG,SRVRVERS);
27 if(!svc_register(transp,SRVRPROG,SRVRVERS,dispatch,IPPROTO_UDP)){
28 fprintf(stderr,"could not register service 1\n");
31 sockets[0]=transp->xp_sock;
33 transp = svcudp_create(RPC_ANYSOCK);
35 fprintf(stderr,"could not create an RPC2 server\n");
38 pmap_unset(SRVRPROG,SRVRVERS+1);
39 if(!svc_register(transp,SRVRPROG,SRVRVERS+1,dispatch,IPPROTO_UDP)){
40 fprintf(stderr,"could not register service 2\n");
43 sockets[1]=transp->xp_sock;
48 fprintf(stderr,"should never reach this point!\n");
51 void dispatch(rqstp,transp) struct svc_req *rqstp; SVCXPRT *transp; {
55 switch( rqstp->rq_proc ){
59 if(!svc_sendreply(transp,xdr_void,0)){
60 fprintf(stderr,"could not reply to RPC NULL call\n");
67 if(sem>1){ printf("ERROR sem=%d\n",sem); exit(1); }
70 if(!svc_getargs(transp,xdr_wrapstring,&s)){
71 fprintf(stderr,"could not decode arguments in RPC render call\n");
75 if(!svc_sendreply(transp,xdr_void,0)){
76 fprintf(stderr,"could not reply to RPC render call\n");
79 if(rqstp->rq_vers-SRVRVERS==1)
87 if(!svc_sendreply(transp,xdr_void,0)){
88 fprintf(stderr,"could not reply to RPC END call\n");
91 svc_unregister(SRVRPROG,rqstp->rq_vers);
93 printf("server %d closed\n",rqstp->rq_vers-SRVRVERS);
96 svcerr_noproc(transp);
100 svc_freeargs(transp,xdr_wrapstring,&s);
108 readfds=svc_fds&mask;
109 /* printf("sel:svc_fds=%x\n",svc_fds);*/
111 printf("server has no services - closing\n");
114 switch( select(32,&readfds,NULL,NULL,NULL) ){
116 case -1: perror("rstat: select");
122 /* printf(" req:svc_fds=%x\n",readfds);*/