[comp.sys.sun] Help request -- RPC/XDR

fsfacca@zoso.lerc.nasa.gov (Tony Facca) (12/09/90)

I am starting to develop some routines which will send binary data from
the Cray (and others) to the Iris.  I want to send the data directly over
the network.  I will have a send routine on the Cray and a receive routine
on the Iris.  I am attempting to use the XDR routines which both
architectures support.  

I muddled through the Sun Network Programming Guide and got a couple of
the simple examples to work.  I still seem to be missing the point.  As
soon as I try a more complicated transfer, like an array of int, I get an
error on the receive side.  I used RPCGEN to generate the XDR code from
the following:

	struct integer_array {
	   int int_data<>;
	};

This generates what looks like a pretty usable XDR module
xdr_integer_array.  I then stuff calls into the reader and writer
routines:

	xdr_integer_array(&xdrs, i_array)

where i_array is the array of integers I want to pass.  Well this doesn't
work straight away, so I've tried all the different variations on the
declarations and can't seem to pin down the problem.  

What I would like to know is:

o are there any better tutorial-style RPC/XDR manuals available anywhere?

o is it really possible to send arrays of data like this (I assumed so
  since it was possible to send structures) or is it customary to send one
  value at a time?

o is anyone willing to share experiences and perhaps some sample code for
  serializing/deserializing binary data using XDR?

Thanks for any reply's.  
Tony Facca   |   fsfacca@avelon.lerc.nasa.gov      |     phone: 216-433-8318

TAYBENGH@NUSDISCS.BITNET (01/01/91)

...STUFF DELETED
|error on the receive side.  I used RPCGEN to generate the XDR code from
|the following:
|
|       struct integer_array {
|          int int_data<>;
|       };
|
|This generates what looks like a pretty usable XDR module
|xdr_integer_array.  I then stuff calls into the reader and writer
|routines:
|
|       xdr_integer_array(&xdrs, i_array)
|
|where i_array is the array of integers I want to pass.  Well this doesn't
|work straight away, so I've tried all the different variations on the
|declarations and can't seem to pin down the problem.

I think you should have passed the structure - integer_array to the above
routine instead of the array of integers, since you specify integer_array
as a struct. If you want to pass the array of integers instead of struct,
you should specify the definition of the array of integers (variable
length) in XDR (see pg 59, of Sun Network Progrmming Guide) as follows:

        int int_data<>;

| ...STUFF DELETED
|o is it really possible to send arrays of data like this (I assumed so
|  since it was possible to send structures) or is it customary to send one
|  value at a time?

Yes, it is possible to send arrays of integers using notation [] (fixed
length) or <> (variable length), as documented in RPCGEN Programming Guide
(chapter 3).

Hope this helps.

Beng Hang (email: taybengh@nusdiscs)