ct_con_drop

Description

Deallocates a connection handle.

Syntax

CS_RETCODE cs_con_drop(context, connection);
CS_CONTEXT     *context;
CS_CONNECTION  *connection;

Parameters

connection

(I) Handle for this connection. This must be the same value specified in the ct_con_alloc call that initialized this connection.

Returns

ct_con_drop returns one of the following values:

Value

Meaning

CS_SUCCEED (-1)

The routine completed successfully.

CS_FAIL (-2)

The routine failed.

The most common reason for a ct_con_drop failure is that the connection is still open.

TDS_CONNECTION_TERMINATED(-4997)

The connection is not active.

Examples

Example 1

The following code fragment demonstrates how ct_con_drop and other functions at the end of a program close the connection and return to CICS. It is taken from the sample program SYCTSAA6 in Appendix A, “Sample Language Application.”

  	/********************************************************************/
  	/*                                                                  */
  	/* Subroutine to perform drop command handler, close server         */
  	/* connection, and deallocate Connection Handler.                   */
  	/*                                                                  */
  	/********************************************************************/
  	void   close_connection ()
  	{
   	CS_INT        rc;
  
  	/*------------------------------------------------------------------*/
  	/* drop the command handle                                          */
  	/*------------------------------------------------------------------*/
         rc = ct_cmd_drop (cmd);
         if (rc == CS_FAIL)
         {
            strncpy (msgstr, "CT_CMD_DROP failed", msg_size);
            error_out (rc) ;
         }
  	/*------------------------------------------------------------------*/
  	/* close the server connection                                      */
  	/*------------------------------------------------------------------*/
         rc = ct_close (connection, (long) CS_UNUSED);
         if (rc == CS_FAIL)
         {
            strncpy (msgstr, "CT_CLOSE failed", msg_size);
            error_out (rc) ;
         }
  	/*------------------------------------------------------------------*/
  	/* De_allocate the connection handle                                */
  	/*------------------------------------------------------------------*/
         rc = ct_con_drop (connection);
         if (rc == CS_FAIL)
         {
            strncpy (msgstr, "CT_CON_DROP failed", msg_size);
            error_out (rc) ;
         }
  }   /* end close_connection */
  
  	/********************************************************************/
  	/*                                                                  */
  	/* Subroutine to perform exit client library and deallocate context */
  	/* structure.                                                       */
  	/*                                                                  */
  	/********************************************************************/
  	void   quit_client_library ()
  	{
   	CS_INT        rc;
  	/*------------------------------------------------------------------*/
  	/* Exit the Client Library                                          */
  	/*------------------------------------------------------------------*/
         rc = ct_exit (context, (long) CS_UNUSED);
         if (rc == CS_FAIL)
         {
            strncpy (msgstr, "CT_EXIT failed", msg_size);
            error_out(rc) ;
          }
  	/*------------------------------------------------------------------*/
  	/* De-allocate the context structure                                */
  	/*------------------------------------------------------------------*/
         rc = cs_ctx_drop (context);
         if (rc == CS_FAIL)
         {
            strncpy (msgstr, "CT_CTX_DROP failed", msg_size);
            error_out(rc) ;
         }
         EXEC CICS RETURN ;
  	}   /* end quit_client_library */

Usage

See also

Related functions