OSF DCE Application Development Guide--Core Components
OSF DCE Application Development Guide—Core Components
*/
void test_push(
rpc_ss_pipe_state_t *state,
idl_char *buf,
unsigned32 count
)
{
unsigned_char_t *cptr;
for (cptr = buf; cptr < buf + count; cptr++)
{
/* For the second, directory reading example,
uncomment the following:
if (*cptr == 0)
*cptr = ’0;
*/
putchar(*cptr);
}
}
For an out pipe, the client code must do the following:
1. Allocate the test_pipe_t structure.
2. Initialize the test_pipe_t.push and test_pipe_t.state fields.
3. Pass the structure as the pipe parameter, either by value or by reference.
test_pipe_t test_pipe;
test_pipe.alloc = (void (*)())client_alloc;
test_pipe.push = (void (*)())test_push;
test_pipe.state = (rpc_ss_pipe_state_t)&out_test_pipe_state;
pipe_test2(binding_h, cmd, &test_pipe, &status);
The client stub unmarshals chunks of the pipe into a buffer and calls back to the
application, passing a reference to the buffer. To allow the application code to manage
its memory usage, and possibly avoid unnecessary copying, the client stub first calls
back to the application’s test_pipe.alloc routine to get a buffer. In some cases, this may
result in the test_pipe.push routine’s not having any work to do.
The client stub may go through more than one (test_pipe.alloc, test_pipe.push) cycle in
order to unmarshal data that the server marshalled as a single chunk. Note that there is
no guarantee that chunks seen by the client stub will match the chunks supplied by the
server’s push routine.
16.4.3 Pipe Summary
The pipe examples show how the client and server tasks are complementary. The client
implements the appropriate callback routines (test_pipe.alloc and either test_pipe.push
16 − 30 Tandem Computers Incorporated 124245