/* client code */ #include #include #include #include #include "date.h" main(argc, argv) int argc; char **argv; { CLIENT *cl; /* rpc handle */ char *server; long *lresult; /* return from bin_date_1 */ char **sresult; /* return from str_date_1 */ if (argc != 2) { fprintf(stderr, "usage: %s hostname\n", argv[0]); exit(1); } server = argv[1]; /* get the name of the server */ /* create the client handle */ if ((cl=clnt_create(server, DATE_PROG, DATE_VERS, "netpath")) == NULL) { /* failed! */ clnt_pcreateerror(server); exit(1); } /* call the procedure bin_date */ if ((lresult=bin_date_1(NULL, cl))==NULL) { /* failed ! */ clnt_perror(cl, server); exit(1); } printf("time on %s is %ld\n", server, *lresult); /* have the server convert the result to a date string */ if ((sresult=str_date_1(lresult, cl)) == NULL) { /* failed ! */ clnt_perror(cl, server); exit(1); } printf("date is %s\n", *sresult); clnt_destroy(cl); /* get rid of the handle */ exit(0); }