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: perist\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 persist example. A connection is established,
- * two remote procedure calls are made, then the connection is closed.
- * Persistent connections save on overhead associated with connection
- * establishment and closing.
- *
- */
-
- #include <stdio.h>
- #include "persist.h" /* client header file, created by 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;
-
- /* declare variable of type connection_id for process binding
- * for a persistent connection.
- */
- connection_id conn;
-
- main()
- {
- int arg1, arg2;
- int result;
- int i;
-
- sname = Server_Name;
-
- /* Establish connection using start procedure */
-
- printf("CLIENT: attempting to establish a connection\n");
- result = start(sname);
-
- if (_rpcerr_) { /* check RPC return code */
- printf("CLIENT: RPC error %d in start() call\n", _rpcerr_);
- exit(1);
- }
- printf("CLIENT: connection established\n");
-
- /* "sleep" for a while */
- printf("CLIENT: sleeping\n");
- {int isleep; for (isleep=0; isleep<=30000; isleep++);}
-
- /* example of call to add() using established connection */
-
- arg1=1234;
- arg2=5678;
- printf("CLIENT: calling add() with %d and %d\n", arg1, arg2);
- result = add(arg1,arg2);
-
- if (_rpcerr_) { /* check RPC return code */
- printf("CLIENT: RPC error %d in add() call\n", _rpcerr_);
- exit(1);
- }
- printf("CLIENT: add() returned %d\n\n", result);
-
- /* "sleep" for a while */
- printf("CLIENT: sleeping\n");
- {int isleep; for (isleep=0; isleep<=30000; isleep++);}
-
- /* example of call to sub() using established connection */
-
- arg1=result;
- arg2=5678;
- printf("CLIENT: calling sub() with %d and %d\n", arg1, arg2);
- result = sub(arg1,arg2);
-
- if (_rpcerr_) { /* check RPC return code */
- printf("CLIENT: RPC error %d in sub() call\n", _rpcerr_);
- exit(1);
- }
- printf("CLIENT: sub() returned %d\n\n", result);
-
- /* "sleep" for a while */
- printf("CLIENT: sleeping\n");
- {int isleep; for (isleep=0; isleep<=30000; isleep++);}
-
- /* Close connection using stop procedure */
- printf("CLIENT: attempting to close connection\n");
- result = stop();
-
- if (_rpcerr_) { /* check RPC return code */
- printf("CLIENT: RPC error %d in stop() call\n", _rpcerr_);
- exit(1);
- }
- printf("CLIENT: connection closed\n");
-
- exit(0);
- }
-