home *** CD-ROM | disk | FTP | other *** search
- /* *
- * *
- * Copyright 1987, 1988, 1989 Netwise, Inc. *
- * All Rights Reserved *
- * This software contains information which is proprietary to and a trade *
- * secret of Netwise, Inc. It is not to be used, reproduced, or disclosed *
- * except as authorized in your license agreement. *
- * *
- * Restricted Rights Legend *
- * Use, duplication, or disclosure by the Government is subject to *
- * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in *
- * Technical Data and Computer Software clause at 252.227-7013, or the *
- * equivalent Government clause for other agencies. *
- * Contractor: Netwise, Inc., Boulder, CO 80301 USA *
- * *
- */
- /*
- * File: timer\client\client.c
- *
- * This example runs in the following environments:
- * NetWare RPC 1.0, NetWare 2.1 or higher, DOS 3.3
- *
- * Client code for the timer example. This program calls two
- * remote procedures, opening and closing the connections for
- * the calls using the non-persistent style of process binding.
- * When a remote procedure is called, customization code in the
- * client stub will cause an error to be returned if the remote
- * procedure does not respond within a specified time period.
- */
-
- #include <stdio.h>
- #include "timer.h" /* client header file, created by the RPC compiler */
-
- extern int _rpcerr_; /* declare RPC error code */
-
- /* Server_Name is used to set the process-binding variable.
- * It must be defined as the name the server registers under.
- */
- #define Server_Name "example"
-
- /* declare variable of type server_name for process binding */
- server_name sname;
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- int arg1, arg2;
- int result;
- int erc;
- int count;
-
- /* If an argument is specified with the -l flag, it is used as the
- * number of times the remote procedure add(), and then the
- * remote procedure sub(), are called. If no argument is given,
- * then both add() and sub() are called only once.
- */
- sname = Server_Name;
-
- if (argc == 3) {
- if (strcmp(*++argv, "-l") == 0)
- /* set number of loops */
- count = atoi(*++argv);
- }
- else
- count = 1;
-
- while (count-- > 0) {
- /* example of call to remote procedure add() */
- arg1=1234;
- arg2=5678;
- printf("CLIENT: calling add() with %d and %d\n", arg1, arg2);
- result = add(arg1,arg2);
-
- /* check RPC error call after remote call */
- if (_rpcerr_) {
- fprintf(stderr,"CLIENT: RPC error %d in add() call\n",
- _rpcerr_);
- exit(1);
- }
- printf("CLIENT: add() returned %d\n", result);
-
- /* example of call to remote procedure sub() */
- arg1=result;
- arg2=5678;
- printf("CLIENT: calling sub() with %d and %d\n", arg1, arg2);
- result = sub(arg1,arg2);
-
- /* check RPC error call after remote call */
- if (_rpcerr_) {
- fprintf(stderr,"CLIENT: RPC error %d in sub() call\n",
- _rpcerr_);
- exit(1);
- }
- printf("CLIENT: sub() returned %d\n", result);
- }
-
- exit(0);
- }
-
-