(Page 8 of 80 in this chapter)


adiClosePort

Description

Closes a port.

Prototype

DWORD adiClosePort( CTAHD ctahd )

ctahd Context handle returned by adiOpenPort.

Return Values

Events

Details

This function aborts all active functions on the port, and releases its resources. Any active asynchronous functions will not receive a DONE event.

adiClosePort is asynchronous and will not have completed executing until the application receives the ADIEVN_CLOSEPORT_DONE event.

Note: If AG Access fails to open a port, it generates an ADIEVN_OPENPORT_DONE event with the value field set to an error code. In response, the application is required to invoke adiClosePort to release the context handle. In this case, the close port function behaves synchronously and an ADIEVN_CLOSEPORT_DONE is not generated. See "Opening Ports" in the Application Development section of the AG Access Developer's Manual for more information.

See Also

adiOpenPort

Example


int myClosePort( CTAHD ctahd )
{
    ADI_EVENT event;

    if( adiClosePort( ctahd ) != SUCCESS )
        return MYFAILURE;

    /* wait for done event */
    while( 1 )
    {
        myGetEvent( &event );           /* see adiFetchAndProcess example */

        switch( event.id )
        {
            case ADIEVN_CLOSEPORT_DONE:
                if( IS_ADI_ERROR( event.value ) )
                    return MYFAILURE;       /* AG Access API error */
                else
                    return SUCCESS;         /* stopped normally */
                break;
        }
    }
}



(Page 8 of 80 in this chapter)


Tech_Support@nmss.com
Copyright © 1996, Natural MicroSystems, Inc. All rights reserved.