As implied throughout the discussion so far, a program written to make use of CPI Communications is written with the remote program in mind. The local program issues a CPI Communications call for a particular conversation knowing that, in response, the remote program will issue another CPI Communications call (or its equivalent) for that same conversation. To explain this two-sided programming scenario, CPI Communications uses the concept of a conversation state. The state that a conversation is in determines what the next set of actions may be. When a conversation leaves a state, it makes a transition from that state to another.
A CPI Communications conversation can be in one of the following states:
| State | Description |
|---|---|
| Reset | There is no conversation for this conversation_ID. |
| Initialize |
Initialize_Conversation has completed successfully
and a conversation_ID has been
assigned for this conversation.
|
| Send | The program is able to send data on this conversation. This state is applicable only for half-duplex conversations. |
| Receive | The program is able to receive data on this conversation. This state is applicable only for half-duplex conversations. |
| Send-Pending |
The program has received both data and send
control on the same Receive call.
See "Example 7: Error Direction and Send-Pending State" for a discussion of
the Send-Pending state.
This state is applicable only for half-duplex conversations.
|
| Confirm | A confirmation request has been received on this conversation; that is, the remote program issued either a Confirm call or a Send_Data call with send_type set to CM_SEND_AND_CONFIRM, and is waiting for the local program to issue Confirmed. After responding with Confirmed, the local program's end of the conversation enters Receive state. This state is applicable only for half-duplex conversations. |
| Confirm-Send |
A confirmation request and send control have both been
received on this conversation; that is, the remote program
issued a Prepare_To_Receive call with the
prepare_to_receive_type set to
CM_PREP_TO_RECEIVE_SYNC_LEVEL and either
the sync_level is
CM_CONFIRM, or the sync_level is
CM_SYNC_POINT and the conversation is not
currently included in a transaction.
After responding with Confirmed, the local
program's end of the conversation
enters Send state.
This state is applicable only for half-duplex conversations.
|
| Confirm-Deallocate | A confirmation request and deallocation notification have
both been received on this conversation.
For a half-duplex conversation, the remote program issued a
Deallocate call in one of the following situations:
|
| Initialize-Incoming | Initialize_For_Incoming has completed successfully and a conversation_ID has been assigned for this conversation. The program may accept an incoming conversation by issuing Accept_Incoming on this conversation. |
| Send-Receive | The program can send and receive data on this conversation. This state is applicable only for full-duplex conversations. |
| Send-Only | The program can only send data on this conversation. This state is applicable only for full-duplex conversations. |
| Receive-Only | The program can only receive data on this conversation. This state is applicable only for full-duplex conversations. |
A conversation starts out in Reset state and moves into other states, depending on the calls made by the program for that conversation and the information received from the remote program. The current state of a conversation determines what calls the program can or cannot make.
Since there are two programs for each conversation (one at each end), the state of the conversation as seen by each program may be different. The state of the conversation depends on which end of the conversation is being discussed. Consider a half-duplex conversation where Program A is sending data to Program C. Program A's end of the conversation is in Send state, but Program C's end is in Receive state.
Note: CPI Communications keeps track of a conversation's current state, as should the program. If a program issues a CPI Communications call for a conversation that is not in a valid state for the call, CPI Communications will detect this error and return a return_code value of CM_PROGRAM_STATE_CHECK.
The following additional states are required for programs using a sync_level of CM_SYNC_POINT or CM_SYNC_POINT_NO_CONFIRM:
"Support for Resource Recovery Interfaces" discusses synchronization point processing and describes these additional states.
For a complete listing of program calls, possible states, and state transitions, see Appendix C. "State Tables".