DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Programming with Remote Procedure Calls (RPC)

An example of registering multiple versions of a remote procedure

By convention, the first version number of program PROG is PROGVERS_ORIG and the most recent version is PROGVERS.

Suppose there is a new version of the ruser program that returns an unsigned short rather than a long. If we name this version RUSERSVERS_SHORT, then a server that wants to support both versions would do a double register. The same server handle would be used for both of these registrations.

   if (!svc_reg(transp, RUSERSPROG, RUSERSVERS_ORIG,
     nuser, nconf)) {
   	fprintf(stderr, "can't register RUSER service\n");
   	exit(1);
   }
   if (!svc_reg(transp, RUSERSPROG, RUSERSVERS_SHORT,
     nuser, nconf)) {
   	fprintf(stderr, "can't register RUSER service\n");
   	exit(1);
   }
Both versions can be handled by the same C procedure:
   nuser(rqstp, transp)
       struct svc_req *rqstp;
       SVCXPRT *transp;
   {
       unsigned long nusers;
       unsigned short nusers2;
   

switch (rqstp->rq_proc) { case NULLPROC: if (!svc_sendreply(transp, xdr_void, 0)) { fprintf(stderr, "can't reply to RPC call\n"); return (1); } return (0); case RUSERSPROC_NUM: /* * Code here to compute the number of users * and assign it to the variable nusers */ nusers2 = nusers; switch (rqstp->rq_vers) { case RUSERSVERS_ORIG: if (!svc_sendreply(transp, xdr_u_long, &nusers)) { fprintf(stderr,"can't reply to RPC call\n"); } break; case RUSERSVERS_SHORT: if (!svc_sendreply(transp, xdr_u_short, &nusers2)) { fprintf(stderr,"can't reply to RPC call\n"); } break; } default: svcerr_noproc(transp); return; } return (0); }


© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004