'\"macro stdmacro
.if n .pH g3n.spray @(#)spray	40.4 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} spray 3N "" "\&"
.if \nX=1 .ds x} spray 3N ""
.if \nX=2 .ds x} spray 3N "" "\&"
.if \nX=3 .ds x} spray "" "" "\&"
.TH \*(x}
.SH NAME
\f4spray\f1 \- scatter data in order to check the network
.SH SYNOPSIS
\f4#include <rpcsvc/spray.h>\f1
.SH DESCRIPTION
The spray protocol sends packets to a given
machine to test the speed and reliability of communications with that
machine.
.P
The spray protocol is not a C function interface, per se, but can be
accessed using the generic remote procedure calling interface
\f4clnt_call\f1() [see \f4rpc_clnt_calls\fP(3N)].
The protocol sends a packet to the called host.
The host acknowledges receipt of the packet.
The protocol counts the number of acknowledgments and can return that
count.
.P
The spray protocol currently supports the following procedures, which
should be called in the order given:
.TP
\f4SPRAYPROC_CLEAR\fP
This procedure clears the counter.
.TP
\f4SPRAYPROC_SPRAY\fP
This procedure sends the packet.
.TP
\f4SPRAYPROC_GET\fP
This procedure returns the count and the amount of time since the last
\f4SPRAYPROC_CLEAR\fP.
.P
The following
\s-1XDR\s0
routines are available in
\f4librpcsvc\f1:
.P
.nf
\f4xdr_sprayarr\fP
\f4xdr_spraycumul\fP
.fi
.SH EXAMPLE
The following code fragment demonstrates how the spray protocol is used:
.ft 4
.nf
#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 = (u_int)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\en",
		spray_result.counter,
		spray_result.clock.sec,
		spray_result.clock.usec);

.fi
.ft1
.SH SEE ALSO
\f4rpc_clnt_calls\fP(3N),
\f4spray\fP(1M),
\f4sprayd\fP(1M).
