XDR
External Data Representation
XDR is a library of routines which allow a user to transfer
data between computers which have different data storage conventions.
XDR uses an "external data representation"; each kind of data
(bit, byte, short and long integers, reals, double precision reals,
character strings, and so on) has a representation defined in this
system.
For each computer system, there are library routines to convert
data between the computer's native data representation, and the
XDR representation.
To transfer data between computers, then, the user would start
on computer A with data represented in the format native to that
computer and call the appropriate XDR routines
to convert each data item's representation into the portable
format. Then the data, in XDR format, can be written to
a file, or transmitted in other ways, to computer B. On that
computer, the appropriate routines are called to convert the
data from the XDR format into the computer's native format.
XDR routines are especially useful for remote procedure calls (RPC).
In a remote procedure call, two programs, which may be running on
different computers, need to pass data. The first program takes
its data, which is in a local data format, and passes it through an XDR
routine so that it is in XDR format. Then RPC routines transmit the
data. The second program receives the data from an RPC routine, and
calls an XDR routine to convert the data from XDR format to its
local data format.
Usage:
-
Compilation:
-
The user program that calls XDR routines must have the
following include statement:
# include <rpc/xdr.h>
and might also need:
# include <rpc/types.h>
Related Data and Programs:
PLTMG_SINGLE
is a FORTRAN77 finite element program which can use
the XDR library.
Reference:
-
John Bloomer,
Power Programming with RPC,
O'Reilly, 1992,
ISBN: 0937175773.
-
David Gunter,
Client/Server Programming with RPC and DCE,
Que, 1995,
ISBN: 0-7897-0182-0.
-
../../txt/xdr.txt, notes on XDR.
Examples and Tests:
-
xdr_prb.c,
a sample calling program.
-
xdr_prb.csh,
commands to compile, link and run the sample calling program.
-
xdr_prb.out,
the output from a run of the sample calling program.
List of Routines:
-
XDR_BOOL encodes or decodes a boolean value.
-
XDR_BYTES encodes or decodes bytes.
-
XDR_CHAR encodes or decodes a character.
-
XDR_DESTROY can discard the connection between
a file and the XDR translator.
-
XDR_DOUBLE encodes or decodes a double precision
floating point value.
-
XDR_ENUM encodes or decodes an enumerated type.
-
XDR_FLOAT encodes or decodes a (single precision)
floating point value.
-
XDR_GETPOS gets the current position in the XDRS stream.
-
XDR_INT encodes or decodes a four-byte integer.
-
XDR_LONG encodes or decodes a long word.
-
XDR_SETPOS sets the current position in the XDRS stream.
-
XDR_SHORT encodes or decodes a short word (two byte
signed integer).
-
XDR_STRING encodes or decodes a null-terminated string.
-
XDR_U_CHAR encodes or decodes an unsigned char
(an integer between 0 and 255).
-
XDR_U_INT encodes or decodes a four-byte unsigned integer.
-
XDR_U_LONG encodes or decodes an unsigned long word.
-
XDR_U_SHORT encodes or decodes a short word (two byte
unsigned integer).
-
XDR_UNION encodes or decodes a union.
-
XDR_VECTOR encodes or decodes a vector.
-
XDR_VOID encodes or decodes nothing.
-
XDRSTDIO_CREATE can set up a connection between a
file and the XDR translator.
You can go up one level to
the C source codes.
Last revised on 22 February 2006.