ONC+ Developer's Guide

Non-Batched Example

This example is included for reference only. It is a version of the batched client string rendering service, written as a non-batched program.


Example D–13 Unbatched Version of Batched Client

#include <stdio.h>
#include <rpc/rpc.h>
#include "windows.h"

main(argc, argv)
	int             argc;
	char          **argv;
{
	struct timeval  total_timeout;
	register CLIENT *client;
	enum clnt_stat  clnt_stat;
	char            buf[1000], *s = buf;

	if ((client = clnt_create(argv[1], WINDOWPROG, WINDOWVERS,
	            "CIRCUIT_V")) == (CLIENT *) NULL) {
		clnt_pcreateerror("clnt_create");
		exit(1);
	}
	total_timeout.tv_sec = 20;
	total_timeout.tv_usec = 0;
	while (scanf("%s", s) != EOF) {
		if(clnt_call(client, RENDERSTRING, xdr_wrapstring, &s,
		    xdr_void, (caddr_t) NULL, total_timeout) != RPC_SUCCESS) {
			clnt_perror(client, "rpc");
			exit(1);
		}
	}
	clnt_destroy(client);
	exit(0);}