A:
Turn to page 269 of the RPCGEN handout (section 22.4).
Read the list of "Eight steps to a distributed program".
Do step 1
Do step 2
Do step 3
...
What if you don't have the handouts?
Send mail to netprog@cs.rpi.edu with the subject line set to the
following:
Subject: I HAVEN'T BEEN TO CLASS IN 3 WEEKS SO I DON'T HAVE THE
HANDOUTS
and we will arrange to get you the handouts.
A: Sun rpcgen
automatically includes rpc/rpc.h in the header file created. AIX
rpcgen does not seem to do this. You need to add the include in all
the files that you create (the client main() and the server stubs).
A:
On AIX you need to check what protocol you are specifying when you
create the client handle. If you copied code from the sample project
that was generated by SUN rpcgen - the value was "netpath" which does
not work on AIX - you should use "tcp" or "udp".
A: Make sure that you
are passing the address of all parameters to the client stubs and that
you are looking for the address of the return values. Everything is
passed and returned by reference. Check out the code generated by
rpcgen and make sure you are calling the client stubs correctly. If
your server is bombing - make sure that the return value of your
server procedures (the functions called by the dispatcher) are
returning a pointer to the result, and that the result exists
even after the function has returned (you can use globals or static
locals for this).
NOTE: returning a pointer to an XDR string parameter means (in C) that you
return a char **, not a char *.
If you still have problems, package up your code (as if you were submitting) and send it to netprog@cs.rpi.edu with a description of the problem and we will be happy to help.
A:
No, this was a mistake. These pages contain some source code
including:
A:
Different versions will generate different kinds of code. For
example, the Sun versions of rpcgen will produce K&R C code which
does not include full prototypes (in the header file). This code
will compile with gcc (don't give it the -ansi option), or you can
tell rpcgen to generate ASNI C by including the "-C" command line
option. Check the rpcgen man page for more details.
A:
The server. (Actually, it's probably easier to check for a division by
zero attempt rather than an actual error.)
i = add_num(no_of_inputs, int_array, &sum);I'm passing a pointer to sum, and I'd like the server to give sum a value, so that I get the sum from the server, at the same time I'm getting a return value (i). Will RPC allow this?
A:
No; you have to return both i and sum in a structure from the procedure.
Q:
Can I have just one function that adds unlimited number of integers?
If you just send it two, it just adds the two. If you send it more,
it adds however many you sent.
A:
Sure.
Q:
Should I just sent strings back and forth? It seems to me that
if I want to add an unlimited number of integers, I'd just stuff
them in a string separated by a space and have the server parse
it and send the answer back.
A:
No, that's not what we want. Nor do we want the client to simply
make a bunch of requests to a remote procedure that adds 2 integers.
We want a remote procedure that can accept a variable number of
integers and will return the sum (as an integer).
XDR supports variable length arrays - check out page 137 of the XDR handout.
Q:
Do we have to report the type of error that occurred (i.e. div by 0) or can we
just say that an error occurred?
A:
You can just say that an error occurred, but make sure that there is
no case when the client could interpret the result as an error when
it was not one. For example, if you return a single value from the
division procedure and assume "-1" means an error, what happens if the
result of the division is -1?
We are trying to make sure you must return a non-simple type. If you try hard enough you can probably get around this, but you will probably end up doing more work than simply returning a struct.
Q:
I think your isdigit in "simple.c" would croak on a plus or minus sign?
A:
Fixed in simple.c, but keep in mind that the code is for your use if
you want it (you don't need to use it), and that if it does not do what
you want you can change it.
Q:
simple.c does not compile.
A:
simple.c isn't
meant to be compiled; it's just an example of how to start things
off.
Q:
Who is HAL ? Who's the guy asking the questions ?
A:
HAL is a computer; HAL and and Dave (the guy asking questions) are
from the movie 2001 Space Odyssey.
A possibly interesting note: HAL is 'I'-1, 'B'-1, 'M'-1