[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Communications Programming Concepts

Broadcasting a Remote Procedure Call Example

The following example illustrates broadcast Remote Procedure Call (RPC):

#include <rpc/pmap_clnt.h>
    ...
enum clnt_stat     clnt_stat;
    ...
clnt_stat = clnt_broadcast(prognum, versnum, procnum,
  inproc, in, outproc, out, eachresult)
    u_long    prognum;      /* program number                */
    u_long    versnum;      /*  version number               */
    u_long    procnum;      /*  procedure number             */
    xdrproc_t inpro         /*  xdr routine for args         */
    caddr_t   in;           /*  pointer to args              */
    xdrproc_t outproc       /*  xdr routine for results      */
    caddr_t   out;          /*  pointer to results           */
    bool_t  (*eachresult)();/*  call with each result gotten */

The eachresult procedure is called each time a result is obtained. This procedure returns a Boolean value that indicates whether the caller wants more responses.

bool_t done;
    ... 
done = eachresult(resultsp, raddr)
    caddr_t resultsp;
    struct sockaddr_in *raddr; /*  Addr of responding machine  */

If the done parameter returns a value of True, then broadcasting stops and the clnt_broadcast routine returns successfully. Otherwise, the routine waits for another response. The request is rebroadcast after a few seconds of waiting. If no response comes back, the routine returns with a value of RPC_TIMEDOUT.


[ Previous | Next | Contents | Glossary | Home | Search ]