An application can handle Client-Library and server messages using one of two methods:
Callbacks – the application installs its own routines to handle Client-Library and server messages. When a message is generated, Client-Library calls the appropriate callback and passes details about the message using the callback’s input parameters.
Inline message handling – in mainline code, the application periodically calls ct_diag to retrieve messages.
Callbacks have these advantages:
They are relatively automatic. Once installed, callbacks are triggered whenever a message occurs.
They centralize message-handling code.
They provide a way for an application to gracefully handle unexpected errors. An application that handles errors using the inline method may not successfully trap unanticipated errors.
Inline error handling, on the other hand, has the advantage of operating under an application’s direct control, which allows an application to check for messages at particular times. For example, an application might call ct_con_props a dozen times to customize a connection but check for errors only after the last call.
Most applications use callbacks to handle messages, but an application that is running on a platform-and-language combination that does not support callbacks must use the inline method.
An application indicates which method it will use by calling ct_callback to install message callbacks or by calling ct_diag to initialize inline message handling.