External Data Representation

XDR is a C library which allows 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.


The user program that calls XDR routines must have the following include statements:
          # include <rpc/types.h>
          # include <rpc/xdr.h> 


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Related Data and Programs:

IRIS_TO_PC a C program which runs on an SGI IRIS and receives data transmitted by the PC_TO_IRIS program.

PC_TO_IRIS a C program which runs on a PC and sends data to be received by the IRIS_TO_PC program.

PLTMG_SINGLE is a FORTRAN77 program which can use the XDR library.


  1. John Bloomer,
    Power Programming with RPC,
    O'Reilly, 1992,
    ISBN: 0937175773.
  2. David Gunter,
    Client/Server Programming with RPC and DCE,
    Que, 1995,
    ISBN: 0-7897-0182-0.

Examples and Tests:

List of Routines:

You can go up one level to the C source codes.

Last revised on 28 July 2016.