An application handles Client-Library and server messages in one of two ways:
By installing callback routines to handle messages
Inline, using the Client-Library routine ct_diag
The callback method has the advantages of:
Centralizing message handling code.
Providing a method to gracefully handle unexpected errors. Client-Library automatically calls the appropriate message callback whenever a message is generated, so an application will not fail to trap unexpected errors. An application using only mainline error-handling logic may not successfully trap errors that have not been anticipated.
Inline message handling has the advantage of allowing an application to check for messages at particular times. For example, an application that is creating a connection might choose to wait until all connection-related commands are issued before checking for messages.
Most applications use the callback method to handle messages. However, 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.
An application uses different methods on different connections. For example, an application installs message callbacks at the context level, allocates two connections, and then calls ct_diag to initialize inline message handling for one of the connections. The other connection will use the default message callbacks that it picked up from its parent context.
An application may switch back and forth between the inline and callback methods:
Installing either a client message callback or a server message callback turns off inline message handling. Any saved messages are discarded.
Likewise, calling ct_diag to initialize inline message handling de-installs a connection’s message callbacks. If this occurs, the connection’s first CS_GET call to ct_diag will retrieve a warning message to this effect.
If a callback of the proper type is not installed and inline message handling is not enabled, Client-Library discards message information.