[LIP] ONC RPC
Shantanu Kumar <[email protected]>
| Newsgroups | gmane.user-groups.linux.india.programmers |
|---|---|
| Message-ID | <[email protected]> |
Hi all,
When trying to run the first example of chapter on RPC from UNPv2 by Stevens,
I am constantly getting a segfault (after checkpoint 2, in the client code
appended below). Can anyone please hint on why is this happening? I am using
RHL9 on a P-III box.
The .x fle is as follows:
/* input (argument) */
struct square_in {
long arg1;
};
/* output (result) */
struct square_out {
long res1;
};
program SQUARE_PROG {
version SQUARE_VERS {
/* procedure number 1 */
square_out SQUAREPROC(square_in) = 1;
} = 1;
} = 0x31230000;
The RPC client is as follows:
#include <stdio.h>
#include <rpc/rpc.h>
#include "square.h"
void err_quit(char *format, char *addons) {
printf(format, addons);
exit(1);
}
/* display checkpoint */
void cp(int cpnum) {
printf("\n-----Checkpoint %d-----", cpnum);
}
int main(int argc, char **argv) {
CLIENT *c1;
square_in in;
square_out *p_out;
long val;
if (argc != 3) {
err_quit("%s", "Usage: client <hostname> <integer-value>");
}
cp(1);
/* create RPC client object */
c1 = clnt_create(argv[1], SQUARE_PROG, SQUARE_VERS, "tcp");
cp(2);
/* prepare input params */
val = atol(argv[2]);
printf("\nValue of argv[2] = %d", val);
in.arg1 = 10L;
cp(3);
/* make the RPC call */
p_out = squareproc_1(&in, c1);
cp(4);
/* dunno if it failed or passed */
if (p_out == NULL) {
err_quit("%s", clnt_sperror(c1, argv[1]));
}
else {
printf("Result: %ld\n", p_out->res1);
}
return 0;
}
Regards,
Shantanu
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click