This example is a reduced set of the original RPC client from SUN. Since the code has been simplified, the example does not run anymore. However the code is still quite big. Here are few hints to help you on what the example does and how it works.
main.c is a simple program that calls N times a remote sort procedure on a table of integers. The RPC run-time support is first initialized by calling "ClntUdp_create", then main calls the stub procedure sort_1 which implements marshalling and message sending. Decoding of the result has been removed from the example.
A detailed documentation on the RPC is provided in doc.ps. Read it carefully.
The goal here, is to specialize sort_1. The Sun RPC code consists of
a set of micro-layers, each one devoted to a small task. Since the wanted
result of specialization is to merge together all the micro-layers. We
need to group existing layers/file into one big file which is then specialized.
All files are already included in rsort.c which is the file to specialize.
The source files are gathered in the Sources directory: rsort.c, rsort.config.sml, rsort.actx.c and rsort.sctx.c. The actx file mimics what ClntUdp_create does. Remember that ClntUdp_create does not have to be specialized.
Where to find procedures:
| sort_1 | sort_clnt.c |
| ClntUdp_create | create_udp.c |
| xdr_{int,short,..} | xdr.c |
| xdrmem_{putlong,getpos, ...} | xdr_mem.c |
| xdr_table | sort_xdr.c |
| Xdr_vector | xdr_array.c |
| Xdr_callhdr | xdr.c |
| ClntUdp_send | send_udp.c |
| structure cu_data | cu.h |
| XDR_GETLONG, XDR_PUTLONG | rpc/xdr.h |
| structure XDR (controls encoding/decoding) | rpc/xdr.h |
| XDR_SETPOS | rpc/xdr.h |
Note: this example works only for Sun-OS, not for Linux (problem of includes).