weiss@ENCORE.COM (Rick Weiss) (05/01/91)
I am attempting to use the RPC mechanism in the Dispatch library and although I have been successful in invoking rpc's with arguments, I am having difficulty in sending back a return value. Is it possible to return a value? Has anyone done this, and do you have examples? Thanks
interran@lurch.Stanford.EDU (John Interrante) (05/03/91)
Yes, you can send back a return value to the caller. You need
something like this (I/O error checking omitted):
// Program sending a RPC call.
int DerivedRpcWriter::foobar(int data) {
int reply;
server() << RpcHdr(FOOBAR) << data;
server() >> reply;
return reply;
}
// Another program receiving the RPC call and replying to it. This
// function is a static member function (no 'this'), so that's why
// client and everything else is passed in as arguments.
void DerivedRpcReader::foobar(RpcReader*, RpcHdr&, rpcstream& client) {
int data, reply;
client >> data;
...
client << reply << flush;
}
I haven't had time to start using the Dispatch library in a new
project, so I don't have a more complete example yet.
--
John Interrante / interran@lurch.stanford.edu