遠隔手続きは、コマンド行引数からユーザー ID を受け取り、その入力を 2 倍にした結果をクライアントに送信し、応答を出力して終了します。
static void proc_1(struct svc_req *rqstp, SVCXPRT *handlep) { int input; int result; uid_t *uidp; switch(rqstp->rq_proc) { case NULLPROC: svc_sendreply(handlep, xdr_void, NULL); break; case RPC_TEST_DOUBLE1: if (!svc_getargs(handlep, xdr_int, (caddr_t) &input)) { fprintf(stderr, "Error from svc_getargs¥n"); svcerr_systemerr(handlep); } uidp = (uid_t *) t6get_attr(T6_UID, handlep->xp_tsol_incoming_attrsp); if (uidp == NULL) fprintf(stderr, "Error from t6get_attr.¥n"); else printf("Client's UID is %d¥n", *uidp); result = 2 * input; if (!svc_sendreply(handlep, xdr_int, (caddr_t) &result)) { fprintf(stderr, "Error from sendreply¥n"); svcerr_systemerr(handlep); } svc_freeargs(handlep, xdr_int, (caddr_t) &input); break; default: fprintf(stderr, "Call to unexpected procedure number %d¥n", rqstp->rq_proc); svcerr_noproc(handlep); break; } }