PreviousNext

IDL Pipes Example

To illustrate the IDL implementation of pipes, consider the following IDL fragment:

typedef

pipe element_t pipe_t;

When the code containing this fragment is compiled, the IDL compiler will generate the following declarations in the derived header file:

typedef struct pipe_t {

void (* pull)(

rpc_ss_pipe_state_t state,

element_t *buf,

idl_ulong_int esize,

idl_ulong_int *ecount

);

void (* push)(

rpc_ss_pipe_state_t state,

element_t *buf,

idl_ulong_int ecount

);

void (* alloc)(

rpc_ss_pipe_state_t state,

idl_ulong_int bsize,

element_t **buf,

idl_ulong_int *bcount

);

rpc_ss_pipe_state_t state;

} pipe_t;

The pipe data structure specifies pointers to three separate routines and a pipe state. The client application has to implement these routines for the client stub to call, and the server manager must call the associated routines generated in the server stub.

The pull routine is used for an input pipe. It pulls the next chunk of data from the client application into the pipe. The input parameters include the pipe state, the buffer (*buf) containing a chunk of data, and the size of the buffer (esize) in terms of the number of pipe data elements. The output parameter is the actual count (*ecount) of the number of pipe data elements in the buffer.

The push routine is used for an output pipe. It pushes the next chunk of data from the pipe to the client application. The input parameters include the pipe state, the buffer (*buf) containing a chunk of data, and a count (ecount) of the number of pipe data elements in the buffer.

The alloc routine allocates a buffer for the pipe data. The input parameters include the pipe state and the requested size of the buffer (bsize) in bytes. The output parameters include a pointer to the allocated buffer (**buf), and the actual count (bcount) of the number of bytes in the buffer. The routine allocates memory from which pipe data can be marshalled or into which pipe data can be marshalled. If less memory is allocated than requested, the RPC runtime uses the smaller memory and makes more callbacks to the user. If the routine allocates more memory than requested, the excess memory is not used.

Finally, the state is used to coordinate between the above routines.

For more on how to write the code for the client and server manager, see Topics in RPC Application Development.