Search code examples
macosportrpc

RPC port Map Failure Mac OSX 10.6


I m trying to run a Program using RPC of Adding two numbers on Mac OsX 10.6

Here is what i am doing:

rpcgen -a -C add.x

It generates the files

add.h,add_clnt.c,add_svc.c,add_server.c,add_client.c

Then Compile all the files using:

gcc -g -DRPC_SVC_FG -c -o add_clnt.o add_clnt.c
gcc -g -DRPC_SVC_FG -c -o add_client.o add_client.c
gcc -g -DRPC_SVC_FG -c -o add_xdr.o add_xdr.c
gcc -g -DRPC_SVC_FG -o add_client add_clnt.o add_client.o add_xdr.o 
gcc -g -DRPC_SVC_FG -c -o add_svc.o add_svc.c
gcc -g -DRPC_SVC_FG -c -o add_server.o add_server.c
gcc -g -DRPC_SVC_FG -o add_server add_svc.o add_server.o add_xdr.o

Run server in one remote console

./add_server

Run client in another console

./add_client localhost 23 35

23 and 35 are the number whose sum i want to be printed on the second console. When i execute the following nothing appears on the server console.

If i try an ip address instead of localhost while running client The error is:

RPC:Port mapper Failure

I am using MacOSX 10.6


Solution

  • You are almost there.

    This was done on a Solaris system and you should see something similar on MacOSX.

    After starting the add_server on the remote host, check that add_server has successfully registered with the remote portmapper. E.g.

    remote> cat add.x
    struct add_args {
        int a;
        int b;
    };
    typedef struct add_args add_args;
    bool_t xdr_add_args();    
    
    
    #define ADDPROG ((u_long)0x20000001)
    #define ADDVERS ((u_long)1)
    #define ADD ((u_long)1)   
    extern int *add_1();  
    
    remote> ./add_server &
    remote> rpcinfo -t localhost 536870913
    program 536870913 version 1 ready and waiting
    

    536870913 is 0x20000001 in decimal. See if the remote host can be reached from local host. If yes, then run the add_client.

    local> ping remote
    remote is alive
    local> rpcinfo -t remote 536870913
    program 536870913 version 1 ready and waiting
    local> ./add_clnt remote 23 35