|
#include <rpc/rpc.h>
#include <rpcsvc/spray.h>
. . .
spraycumul spray_result;
sprayarr spray_data;
char buf[100]; /* arbitrary data */
int loop = 1000;
CLIENT *clnt;
struct timeval timeout0 = {0, 0};
struct timeval timeout25 = {25, 0};
spray_data.sprayarr_len = (uint_t)100;
spray_data.sprayarr_val = buf;
clnt = clnt_create("somehost", SPRAYPROG, SPRAYVERS, "netpath");
if (clnt == (CLIENT *)NULL) {
/* handle this error */
}
if (clnt_call(clnt, SPRAYPROC_CLEAR,
xdr_void, NULL, xdr_void, NULL, timeout25)) {
/* handle this error */
}
while (loop- > 0) {
if (clnt_call(clnt, SPRAYPROC_SPRAY,
xdr_sprayarr, &spray_data, xdr_void, NULL, timeout0)) {
/* handle this error */
}
}
if (clnt_call(clnt, SPRAYPROC_GET,
xdr_void, NULL, xdr_spraycumul, &spray_result, timeout25)) {
/* handle this error */
}
printf("Acknowledged %ld of 1000 packets in %d secs %d usecs\n",
spray_result.counter,
spray_result.clock.sec,
spray_result.clock.usec);
|