Searching...
Sunday 8 June 2014

IMPLEMENTATION OF “HELLO WORLD” SERVICE USING RPC(REMOTE PROCEDURE CALL)

6/08/2014 09:05:00 am
firsttry.x
program FIRSTTRYPROG {
            version FIRSTTRYVERS {
                        string FIRSTTRY(void) = 1;
            } = 1;
} = 0x30000824;

Firsttry_server.c
#include "firsttry.h"

char **
firsttry_1_svc(void *argp, struct svc_req *rqstp)
{
           
static char msg[256];
            static char *p;

            printf("getting ready to return value\n");
            strcpy(msg, "Hello world");
            p = msg;
            printf("Returning\n");

            return(&p);

}



Firsttry_client.c
#include <stdio.h>
#include <rpc/rpc.h>
#include "firsttry.h"


main (int argc, char *argv[]) {

            CLIENT *cl;
            char **p;

            cl = clnt_create(argv[1],FIRSTTRYPROG, FIRSTTRYVERS, "tcp");
            if (cl == NULL) {
                        clnt_pcreateerror(argv[1]);
                        exit(1);
            }


            p = firsttry_1(NULL,cl);

            printf("Back from firsttry\n");
            if (p == NULL) {
                        clnt_perror(cl,argv[1]);
                        exit(1);
            }

            printf("Returned string=%s\n",*p);


}

0 comments:

Post a Comment