Communications/Transactions Guide and Reference

Using the RPC/XDR client system layer

RPC/XDR client is supported by two primary classes implemented at the system layer:

In addition, if an error occurs, then an instance of the following class will be returned:

The following sections discuss how you use these classes to establish a connection between your any RPC client and server.

Defining and connecting to a RPC server

Defining and connecting to a RPC server is a six-step process.

  1. Create an instance of the AbtRPCConnectionSpec class
  2. Define the server program number, version and TCP address
  3. Create an instance on the AbtRPCClient class and initialize it
  4. Create a client handle
  5. Initiate the client call
  6. Destroy the client handle

The AbtRPCConnectionSpec object represents the remote host that your application is going to communicate with. To create an instance of this class you need to know either the name or address of the remote host, the program and version numbers. For Example:

connspec := AbtRPCConnectionSpec new
    programNumber: 16r30099999;
    programVersion: 1;
    serverName: 'Lancelot';
    yourself.

Next you need to create a client and initialize it as follows.

result := 
    ((client := AbtRPCClient new) connectionSpec: connspec)
        createClientHandle.

Next you need to define your input and output records and associate them with the client.

inputRecord :=
    (AbtCompoundType new name: 'myinrcd';
        addField: (AbtCUIntField new name: #Field1; yourself);
        addField: (AbtCUIntField new name: #Field2; yourself);
        yourself) newRecord.
outputRecord :=
    (AbtCompoundType new name: 'myoutrcd';
        addField: (AbtCUIntField new name: #Result; yourself);
        yourself) newRecord.
inputRecord at: #Field1 put: 10;
            at: #Field2 put: 20.
outputRecord at: #Result put: 0.
client inputRecord: inputRecord;
       outputRecord: outputRecord.

Next you need to set the function number to be invoked and the expiration time value for the client.

client functionNumber: 1;timeOut: 3000.

Executing the transaction

result := client execute.

The output record will reflect the transaction results or the lastError instance variable will contain an AbtError.

Destroy the client handle

To end the connection to the remote host, execute the following.

result := client destroyHandle.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]