Deallocates a connection handle.
CS_RETCODE cs_con_drop(context, connection); CS_CONTEXT *context; CS_CONNECTION *connection;
(I) Handle for this connection. This must be the same value specified in the ct_con_alloc call that initialized this connection.
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. |
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 */
ct_con_drop deallocates a connection handle and all command handles associated with that connection.
Once a connection handle is deallocated, it cannot be reused. To allocate a new connection handle, an application calls ct_con_alloc.
An application cannot deallocate a connection handle until the connection it represents successfully closes. To close a connection, an application calls ct_close.
Related functions