Using Asynchronous Call Completion

With one exception, SNA Server permits one outstanding Windows SNA asynchronous call per connection and one blocking verb per thread. The exception to this guideline is that when issuing an asynchronous Receive call, the following calls can be issued while the Receive is outstanding:

Cancel_Conversation

Deallocate

Request_To_Send

Send_Error

Test_Request_To_Send_Received

This allows an application, in particular a 5250 emulator, to use an asynchronous Receive to receive data. Use of this feature is strongly recommended.

The following example illustrates how to use asynchronous call completion for SNA Server:

void ProcessVerbCompletion (WPARAM wParam LPARAM lParam)

{
    for ( i = 0; i<nPendingVerbs; i++ )
        if (memcmp  (pPending [i].ConvID, (Conversation_ID) lParam) = = 0)
            ProcessCommand  (wParam, lParam);

}

LRESULT CALLBACK SampleWndProc  ( . . .)

{
    if (msg = = uAsyncCPIC )   {
        ProcessVerbCompletion  (wParam, lParam);
    }
    else switch  (msg)  {
       case WM_USER:
        Initialize_Conversation  ( lpConvId,  "GORDM",  &lError  );
        if  ( lError  ! = CM_OK )   {
            ErrorDisplay ( ) ;
            break ;
        }
        Set_Processing_Mode  ( lpConvId,  CM_NON_BLOCKING,  &lError  ) ;
        if  ( lError ! = CM_OK )  {
            ErrorDisplay ( ) ;
            break ;
        }
        Allocate  ( lpConvId,  &lError )  ;
        switch  ( lError )  {

        case CM_OK:
            break ;

        case CM_OPERATION_INCOMPLETE:
            memcopy  (pPending [nPending ++].ConvId,  lpConvId,  sizeof  (C) ;
            break ;
        default:
            ErrorDisplay ( ) ;

        }
        break ;
}

WinMain  ( . . . )
{
    if  ( ( WinCPICStartup  ( . . . )  =  =  FALSE  )   {
        return FALSE;

    }
    uAsyncCPIC = RegisterWindowMessage  ("WinAsyncCPIC"");
    Specify_Windows_Handle  (hwndSample) ;
    while  (GetMessage  ( . . . )   )   {
    . . . . .
    }
    WinCPICCleanup  ( . . . )

}
 

For more information on CPI-C calls and Windows extensions, see CPI-C Calls and Extensions for the Windows Environment. For additional information on using CPI-C, see the IBM Systems Application Architecture Common Programming Interface Communications Reference, part number SC26-4399-04.