OSF DCE Application Development Guide--Core Components
Topics in RPC Application Development
client_pipe_state_t * state;
byte *buf;
unsigned int esize;
unsigned int *ecount;
{
if ( ! state->file_open )
{
state->file_handle = open(state->filename,O_RDONLY);
if (state->file_handle == -1)
{
printf("Client couldn’t open %s0, state->filename);
exit(0);
}
state->file_open = true;
}
*ecount = read( state->file_handle, buf, esize );
if (*ecount == 0)
{
close(state->file_handle);
state->file_open = false;
}
}
Finally, the client must do the following:
1. Allocate the test_pipe_t structure.
2. Initialize the test_pipe_t.pull, test_pipe_t.alloc, and test_pipe_t.state fields.
3. Include code where appropriate for checking the pipe_t.state field.
4. Pass the structure as the pipe parameter. The structure can be passed either by
value or by reference, as indicated by the signature of the operation that contains
the pipe parameter:
/* Client initializes pipe */
test_pipe_t test_pipe;
test_pipe.pull = client_pull;
test_pipe.alloc = client_alloc;
test_pipe.state = (rpc_ss_pipe_state_t)&client_in_pipe_state;
/* Client makes call */
pipe_test1(binding_h, test_pipe, &status);
To transmit a large amount of data that is already in the proper form in memory (that is,
the data is already an array of test_pipe_t), the client application code can have the alloc
routine allocate a buffer that already has the information in it. In this case, the pull
routine becomes a null routine.
124245 Tandem Computers Incorporated 16− 27