CPI-C Send and Receive TPs

These TPs are CPI-C versions of the APPC send and receive TPs. The sample code illustrates the use of asynchronous CPI-C calls.

Setup

    To set up the send and receive TPs
  1. Create an appropriate APPC LU-LU-mode triplet.
  2. Set up a CPI-C symbolic destination name that contains the configured remote LU and mode. (The default symbolic destination name is CPICRECV.)
  3. Assign the local APPC LU to the CPICSEND TP, either by using a registry entry of CPICSEND:REG_SZ:LocalLUAlias in the SnaBase\Parameters\Clients key, or by assigning the local LU as the default local APPC LU for the user who will run CPICSEND.

For example, use SENDLU-RECVLU-#INTER as your LU-LU-mode triplet. Then create a CPI-C symbolic destination name CPICRECV containing the application TP name CPICRECV, the partner LU alias RECVLU, and the mode name #INTER. Finally, add the intended user to the users list, and assign SENDLU as the user's default local APPC LU.

Input and Output

CPICSEND and CPICRECV use the files CPICSEND.CFG and CPICRECV.CFG for input. These files should be placed in the directory that contains the TP (executable file). These files are similar to the input files for the APPC send and receive TPs.

The following entries are for CPICSEND only:

Line Default value Value to supply
ResultFile = C:\CPICSEND.OUT File name to print timings to.
NumSends = 2 Number of Send_Data calls per conversation.
SendSize = 1024 Size in bytes of data sent each time.
ConfirmEvery = 1 Number of Send_Data calls between Confirm calls.
SymDestName = CPICSEND Symbolic destination name.
NumConversations = Number of conversations. This setting must be the same for CPICSEND and CPICRECV (they do not negotiate the number).
WaitMode= NO YES or NO: Use wait mode with asynchronous call completion. If NO, the TPs issue Specify_Windows_Handle with their window handle so that Windows CPI-C will post completion messages to them. If YES, the TPs issue Specify_Windows_Handle with NULL so that the TPs must then issue the Wait_For_Conversation call to wait for the asynchronous call to complete.

The following entries are for CPICRECV only:

Line Default value Value to supply
LocalTPName = CPICRECV Local TP name to use on Specify_Local_TP_Name call.
NumConversations = Number of conversations. This setting must be the same for CPICSEND and CPICRECV (they do not negotiate the number).
WaitMode= NO YES or NO: Use wait mode with asynchronous call completion. If NO, the TPs issue Specify_Windows_Handle with their window handle so that Windows CPI-C will post completion messages to them. If YES, the TPs issue Specify_Windows_Handle with NULL so that the TPs must then issue the Wait_For_Conversation call to wait for the asynchronous call to complete.

As with SENDTP, CPICSEND produces C:\CPICSEND.OUT (by default) with timings of the conversations in it.

Operation

CPICRECV should be started first; it issues Specify_Local_TP_Name to set its local TP name, and then Accept_Conversation to accept a conversation (note that because Specify_Local_TP_Name is issued, the Accept_Conversation will complete asynchronously).

Both TPs issue Specify_Windows_Handle during initialization to set either the window handle or NULL. CPICSEND calls Set_Processing_Mode after completion of Initialize_Conversation to set the processing mode to nonblocking for this conversation.

After each call is issued, the return code is checked; if it is not cm_operation_incomplete, the call has already completed, so an ASYNC_COMPLETE message is posted to trigger the next call. If WaitMode is set to YES and the issued call did not complete immediately, then a Wait_For_Conversation call is issued to wait for call completion, at which point an ASYNC_COMPLETE message is posted. If WaitMode is set to NO and the issued call did not complete immediately, then Windows CPI-C detects call completion and posts an ASYNC_COMPLETE message. Receipt of the ASYNC_COMPLETE message triggers the next call to be issued.

For CPICSEND, each conversation consists of an Allocate call, followed by a given number of Send_Data calls of given size and interspersed with Confirm calls at a given interval, followed by a Deallocate.

CPICRECV issues Receive on completion of the Accept_Conversation, and then issues either Receive or Confirmed according to the return from the previous Receive.

At any stage, if the TPs encounter an error, they terminate. Use CPI-C API tracing to diagnose problems with the configuration.

Both TPs are built from a single source-code file, CPICSR.C. CPICSEND is compiled only if -DCPICSEND is used on the command line.

The TPs run as Windows NT or Windows 95 applications with a minimized window, the title of which displays the status. When the WndProc of this window, TPWndProc, receives the WM_CREATE message for the window, this triggers the issuing of the first call. When TPWndProc receives an ASYNC_COMPLETE message from Windows CPI-C, this triggers the issuing of the next call, dependent on what the previous call was. When the window is closed, WinCPICCleanup is issued to terminate any active conversations.