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: async1\client\client.c
- *
- * This example works in the following environments:
- * NetWare RPC 1.0, NetWare 2.1 or higher, DOS 3.3
- *
- * This is the driver program for the async1 example. The purpose of this
- * example is to illustrate the use of an non-blocking client stub. This
- * driver program is a C program which simply calls the remote procedures
- * add and subtract and prints the result. poll_reply is called to see if
- * the server has replied.
- */
- #include <stdio.h>
- #include "async1.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()
- {
- int arg1, arg2;
- int result;
- int erc;
- char *cli_rpc_handle;
-
- sname = Server_Name;
-
- /* Example of asynchronous call to add */
- arg1 = 1234;
- arg2 = 5678;
- cli_rpc_handle = (char *)0;
-
- printf("CLIENT: calling add() with %d and %d\n", arg1, arg2);
-
- add(arg1, arg2, &cli_rpc_handle);
-
- for (;;) {
- /*
- * Poll to see if the server has replied.
- */
- erc = poll_reply(cli_rpc_handle);
-
- if (erc == 1)
- /* reply message received from remote procedure */
- break;
- else if (erc == 0) {
- printf("No result yet, try again\n");
- } else {
- /* error from poll_reply(); continue so state
- * machine in client stub can clean up
- */
- printf("CLIENT: error %d in poll_reply()\n", erc);
- break;
- }
-
- }
-
- /*
- * Now that the server has replied, call add again to
- * complete the asynchronous remote procedure call.
- */
- result = add(arg1,arg2, &cli_rpc_handle);
-
- if (_rpcerr_) { /* check RPC error code */
- printf("CLIENT: RPC error %d in add() call\n", _rpcerr_);
- exit(1);
- }
- printf("CLIENT: add() returned %d\n\n", result);
-
- /* Example of asynchronous call to sub() */
- arg1 = result;
- arg2 = 5678;
- cli_rpc_handle = (char *)0;
-
- printf("CLIENT: calling sub() with %d and %d\n", arg1, arg2);
-
- sub(arg1, arg2, &cli_rpc_handle);
-
- for (;;) {
- /*
- * Poll to see if the server has replied.
- */
- erc = poll_reply(cli_rpc_handle);
-
- if (erc == 1)
- /* reply message received from remote procedure */
- break;
- else if (erc == 0) {
- printf("No result yet, try again\n");
- } else {
- /* error from poll_reply(); continue so state
- * machine in client stub can clean up
- */
- printf("CLIENT: error %d in poll_reply()\n", erc);
- break;
- }
- }
-
- /*
- * Now that the server has replied, call sub again to
- * complete the asynchronous remote procedure call.
- */
- result = sub(arg1, arg2, &cli_rpc_handle);
-
- if (_rpcerr_) { /* check RPC error code */
- printf("CLIENT: RPC error %d in sub() call\n", _rpcerr_);
- exit(1);
- }
- printf("CLIENT: sub() returned %d\n\n", result);
-
- exit(0);
- }
-