Communications/Transactions Guide and Reference

Using the CPI-C system layer

This section explains how to use the CPI-C system layer.

Establishing a new conversation

CPI-C sends and receives all messages from remote programs by establishing a conversation with the remote program and then issuing send and receive CPI-C verbs referencing the conversation.

In the implementation of CPI-C, establishing a conversation is accomplished by sending a connectUsing: message to a CPI-C Conversation object and passing it a CPI-C ConnectionSpec object. The following example code shows how to create a new conversation:

aCPICConversation connectUsing: aCPICConnectionSpec.

Sending and receiving messages

Messages are sent to and received from a remote program by calling CPI-C to issue a send or receive verb referencing both the conversation open to the remote program and the local TP that is the logical owner of the conversation. This is achieved in the IBM Smalltalk implementation of CPI-C by sending a send or receive message to an instance of CPI-C Conversation, as in the following example code:

result := aConversation sendRecord: aRecord.
result := aConversation receiveAndWaitDataComplete

In the first line, the result variable contains the result of the sendRecord: message. In the second line, the data received from the remote program is contained in the variable result.

After sending and receiving all the data required from a remote program, the conversation must be deallocated. The designers of the local and remote programs must decide which program will perform the deallocate and when. If the remote program deallocates, no action is required on the part of the local program. However, the local program can initiate the deallocate by sending the message disconnect: to the conversation object.

Detecting errors

When a message is sent to a system layer object that results in a call to the CPI-C subsystem, the possibility exists for an error. Objects in the system layer signal errors to their callers by returning error objects instead of the normal message results. Therefore, after each message is sent to an CPI-C system layer object, it is a good practice to check whether the result represents a CPI-C error. This is done by sending the message isCommunicationsError to the result, as in the following example code:

result := aConversation send: aRecord type: ApNone.
result isCommunicationsError
    ifTrue: [result display].

Using CPI-C in Windows 95 and Windows NT

On the Windows 95 and Windows NT environments CPI-C support in VisualAge Smalltalk supports both the IBM and AttachMate products. The IBM product is set as the default support for both platforms. To change support between the two vendors, execute the following from the Smalltalk Transcript window:

USING CPI-C IN AIX

In AIX, CPI-C support in VisualAge Smalltalk supports both version 2.2 and version 3.1.1 of Communications Server. Version 3.1.1 is set as the default. To change between the two libraries, execute the following:

To switch to version 2.2 support execute the following:

AbtCPCIBaseUnixSubApp ver22

To switch to version 3.1.1 suport execute the following:

AbtCPCIBaseUnixSubApp ver3110


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