home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 11 / 11.iso / n / n001 / 2.ddi / EXAMPLES / TIMER / CLIENT / CLIENT.C next >
Encoding:
C/C++ Source or Header  |  1989-12-11  |  3.4 KB  |  101 lines

  1. /*                                                                            *
  2.  *                                                                            *
  3.  *                  Copyright 1987, 1988, 1989 Netwise, Inc.                  *
  4.  *                              All Rights Reserved                           *
  5.  *   This software contains information which is proprietary to and a trade   *
  6.  *   secret of Netwise, Inc. It is not to be used, reproduced, or disclosed   *
  7.  *   except as authorized in your license agreement.                          *
  8.  *                                                                            *
  9.  *                          Restricted Rights Legend                          *
  10.  *   Use, duplication,  or  disclosure  by the  Government  is  subject  to   *
  11.  *   restrictions as set forth in subparagraph (c)(1)(ii) of the Rights  in   *
  12.  *   Technical Data and  Computer Software clause  at 252.227-7013, or  the   *
  13.  *   equivalent Government clause for other agencies.                         *
  14.  *   Contractor: Netwise, Inc., Boulder, CO 80301 USA                         *
  15.  *                                                                            *
  16.  */ 
  17. /*
  18.  * File: timer\client\client.c
  19.  *
  20.  * This example runs in the following environments:
  21.  *    NetWare RPC 1.0, NetWare 2.1 or higher, DOS 3.3
  22.  *
  23.  * Client code for the timer example.  This program calls two
  24.  * remote procedures, opening and closing the connections for
  25.  * the calls using the non-persistent style of process binding.
  26.  * When a remote procedure is called, customization code in the
  27.  * client stub will cause an error to be returned if the remote
  28.  * procedure does not respond within a specified time period.
  29.  */ 
  30.  
  31. #include <stdio.h>
  32. #include "timer.h"    /* client header file, created by the RPC compiler */
  33.  
  34. extern int _rpcerr_;    /* declare RPC error code */
  35.  
  36. /* Server_Name is used to set the process-binding variable.
  37.  * It must be defined as the name the server registers under.
  38.  */
  39. #define Server_Name  "example"
  40.  
  41. /* declare variable of type server_name for process binding */
  42. server_name sname;
  43.  
  44. main(argc, argv)
  45. int argc;
  46. char *argv[];
  47. {
  48.     int arg1, arg2;
  49.     int result;
  50.     int erc;
  51.     int count;
  52.  
  53. /* If an argument is specified with the -l flag, it is used as the
  54.  * number of times the remote procedure add(), and then the
  55.  * remote procedure sub(), are called.  If no argument is given,
  56.  * then both add() and sub() are called only once.
  57.  */
  58.     sname = Server_Name;
  59.  
  60.     if (argc == 3) {
  61.         if (strcmp(*++argv, "-l") == 0)
  62.             /* set number of loops */
  63.             count = atoi(*++argv);
  64.         }
  65.     else
  66.         count = 1;
  67.  
  68.     while (count-- > 0) {
  69.         /* example of call to remote procedure add() */
  70.         arg1=1234;
  71.         arg2=5678;
  72.         printf("CLIENT: calling add() with %d and %d\n", arg1, arg2);
  73.         result = add(arg1,arg2);
  74.  
  75.         /* check RPC error call after remote call */
  76.         if (_rpcerr_) {
  77.             fprintf(stderr,"CLIENT: RPC error %d in add() call\n",
  78.                                       _rpcerr_);
  79.             exit(1);
  80.         }
  81.         printf("CLIENT: add() returned %d\n", result);
  82.  
  83.         /* example of call to remote procedure sub() */
  84.         arg1=result;
  85.         arg2=5678;
  86.         printf("CLIENT: calling sub() with %d and %d\n", arg1, arg2);
  87.         result = sub(arg1,arg2);
  88.  
  89.         /* check RPC error call after remote call */
  90.         if (_rpcerr_) {
  91.             fprintf(stderr,"CLIENT: RPC error %d in sub() call\n",
  92.                 _rpcerr_);
  93.             exit(1);
  94.         }
  95.         printf("CLIENT: sub() returned %d\n", result);
  96.     }
  97.  
  98.     exit(0);
  99. }
  100.  
  101.