CPI-C Reference


Verifying Receipt of Data

This section provides an example of a program validating receipt of data.

Example 5: Validation of Data Receipt

Figure 14 shows how a program can use the Confirm and Confirmed calls on a half-duplex conversation to verify receipt of its sent data. The Flush call is also shown.

The steps shown in Figure 14 are:
Step Description
(1) and (2) As before, Program A issues the Initialize_Conversation call to initialize the conversation.
(3) and (4) Program A issues a new call, Set_Sync_Level, to set the sync_level characteristic to CM_CONFIRM.

Note: Program A must set the sync_level characteristic before issuing the Allocate call (Step (5)) for the value to take effect. Attempting to change the sync_level after the conversation is allocated results in an error condition. See Set_Sync_Level (CMSSL) for a detailed discussion of the sync_level characteristic and the meaning of CM_CONFIRM.

(5) and (6) Program A issues the Allocate call to start the conversation.
(7) and (8) Program A uses the Flush call (see Flush (CMFLUS)) to make sure that the conversation is immediately established. If data is present, the local system buffer is emptied and the contents are sent to the remote system. Since no data is present, only the conversation startup request is sent to establish the conversation.

At System Y, the conversation startup request is received. Program C is started and begins processing.

(9)and (10) Program A issues a Send_Data call. Program C issues an Accept_Conversation call.
(11) Program A issues a Confirm call to make sure that Program C has received the data and performed any data validation that Programs A and C have agreed upon. Program A is forced to wait for a reply.
(12) and (13) Program C issues a Receive call and receives the data with status_received set to CM_CONFIRM_RECEIVED.
(14) and (15) Because status_received is set to CM_CONFIRM_RECEIVED, indicating a confirmation request, the conversation has been placed into Confirm state. Program C must now issue a Confirmed call. After Program C makes the Confirmed call (see Confirmed (CMCFMD)), the conversation returns to Receive state. Meanwhile, at System X, the confirmation reply arrives and the CM_OK return_code is sent back to Program A.
(16) Program A continues with further processing.

Note: Unlike the previous examples in which a program could bypass waiting, this example demonstrates that use of the Confirm call forces the program to wait for a reply.

Figure 14. Validation and Confirmation of Data Reception

           System X                                                       System Y 
 *-------------------------------*                           *-------------------------------*
 | *-------*    *--------------* |                           | *--------------*    *-------* |
 | |Program|    |     CPI      | *---------------------------* |     CPI      |    |Program| |
 | |   A   |    |Communications| |                           | |Communications|    |   C   | |
 | *.------*    *-------------.* |                           | *.-------------*    *------.* |
 *--.-------------------------.--*                           *--.-------------------------.--*
    .                         .                                 .                         .
    Initialize_Conversation (sym_dest_name)                     .                         .
(1) .*----------------------->.                                 .                         .
  conversation_ID, return_code=CM_OK                            .                         .
(2) .<------------------------.                                 .                         .
    .                         .                                 .                         .
    Set_Sync_Level(CM_CONFIRM).                                 .                         .
(3) .------------------------>.                                 .                         .
    .    return_code=CM_OK    .                                 .                         .
(4) .<------------------------.    Logical connection setup,    .                         .
    .                         .      if logical connection      .                         .
    .Allocate(conversation_ID).      not already available      .                         .
(5) .*----------------------->.<------------------------------->.                         .
    .    return_code=CM_OK    .                                 .                         .
(6) .<------------------------.                                 .                         .
    .                         .                                 .                         .
    . Flush(conversation_ID)  .  conversation startup request   .                         .
(7) .------------------------>.-------------------------------->.                         .
    .    return_code=CM_OK    .                                 .(Program C is started by .
(8) .<------------------------.                                 .     node services)      .
    .                         .                                 .                         .
    . Send_Data(conversation_ID, data)                          .   Accept_Conversation   .
(9) .*----------------------->.                                 .<-----------------------*.
    .    return_code=CM_OK    .                              conversation_ID, return_code=CM_OK
(10).<------------------------.                                 .------------------------>.
    .                         .                                 .                         .
    .Confirm(conversation_ID) .    confirmation request, data   .                         .
(11).------------------------>.-------------------------------->.                         .
    .  (Program A waits for   .                                 . Receive(conversation_ID).
(12).     a reply from        .                                 .<-----------------------*.
    .     Program C)          .                                 .          data,          .
    .                         .                              status_received=CM_CONFIRM_RECEIVED
(13).                         .                                 .*----------------------->.
    .                         .                                 .                         .
    .    return_code=CM_OK    .       confirmation reply        .Confirmed(conversation_ID)
(14).<------------------------.<--------------------------------.<-----------------------*.
    .                         .                                 .    return_code=CM_OK    .
(15).                         .                                 .------------------------>.
    . Send_Data(conversation_ID, data)                          .                         .
(16).*----------------------->.                                 .                         .
    .                         .                                 .                         .
    .                        (further processing by both programs)                        .
    .                         .                                 .                         .


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