The following steps show a simple Client-Library application:
Set up the Client-Library programming environment:
Use cs_ctx_alloc to allocate a context structure.
Use cs_config to set any CS-Library properties for the context.
Use ct_init to initialize Client-Library.
Use ct_config to set Client-Library properties for the context.
Define error handling. Most applications use callback routines to handle errors:
Use cs_config(CS_MESSAGE_CB) to install a CS-Library error callback.
Use ct_callback to install a client message callback.
Use ct_callback to install a server message callback.
WARNING! Applications that do not define error handling do not receive notification of errors that occur in the program, on the network, or on the server. Code your applications to handle errors and server messages. Applications that do not perform error handling are difficult to debug and maintain.
Connect to a server:
Use ct_con_alloc to allocate a connection structure.
Use ct_con_props to set any properties in the connection structure
Use ct_connect to open a connection to a server.
Use ct_options to set any server options for this connection.
Send a language command to the server:
Use ct_cmd_alloc to allocate a command structure.
Use ct_command to initiate a language command.
Use ct_send to send the command.
Process the results of the command:
Use ct_results to set up results for processing (called in a loop).
Use ct_res_info to get information about a result set.
Use ct_describe to get information about a result item.
Use ct_bind to bind a result item to program data space.
Use ct_fetch to fetch result rows (called in a loop).
Finish:
Use ct_cmd_drop to deallocate the command structure.
Use ct_close to close the connection with the server.
Use ct_exit to exit Client-Library.
Use cs_ctx_drop to deallocate the context structure.