Using RPC under the OS9 operating system

# Example: Client on VMS, server on OS9.

##

See also: running under OS9 , running under VMS .

The general procedure is as described in running under OS9 :

- Write the server, client, and variable declaration files
- RPC the declaration file with correct options
- Link the client modules on the VAX (for this application)
- Port the server routines, compile, and link with RPC files
- Define the logical/environment variables(=addresses)
- Run the application

The client program is as follows:

         #include <stdio.h>
         #include <rpcrts.h>
         	extern void open_test_2();
            extern rpc_long testfun_2();

         main()
         {
            int a,b;

            open_test_2();		/* connect us to the server */

            a = 1;
            b = 9;
            printf("\n A = %d   B = %d", a, b);
            printf("\n A + B =  %d", testfun_2(a,b));
         }

The pacakge definition file is as follows:

          PACKAGE TEST_2 IS
                  FUNCTION TESTFUN_2 (
                  		P1 : IN RPC_LONG;
    			P2 : IN RPC_LONG)
    			RETURN RPC_LONG;
          END TEST_2;

Here is the server program:

         #include <rpcrts.h>
         #include <stdio.h>
         #include <types.h>

             extern void attach_test_2();
             extern void rpc_init();

         main()
         {
            rpc_status status;

            rpc_init();
            attach_test_2();

            rpc_loop_server(&status,"RPC_CLIENT_NAME                        ");
            rpc_report_error(&status);
         }

         testfun_2(p1,p2)
         int     p1,p2;
         {
            return(p1 + p2);
         }

To run it, Define the addresses, under OS9:

    	SETENV RPC_CLIENT_NAME  AA_00_04_00_15_58_5680.ETHERNET

or, to service requests from any address,

    	SETENV RPC_CLIENT_NAME  "*_5680.ETHERNET"

and on the VAX:

            VAX:  DEFINE TEST_2 0@02_60_86_00_04_4E_5680.ETHERNET

Then start the server and run the client.