TipcConnErrorCbCreate create an error callback in a connection
T_CB TipcConnErrorCbCreate(conn
,func
,arg
) T_IPC_CONNconn
; T_IPC_CONN_ERROR_CB_FUNCfunc
; T_CB_ARGarg
;
conn
connection for which to create callback
func
callback function
arg
user-defined argument to pass to func
New callback if successful, NULL
otherwise.
If TipcConnErrorCbCreate fails, it returns NULL
and sets the global SmartSockets error number to one of:
TipcConnErrorCbCreate creates an error callback in a connection. These callbacks are called when an unrecoverable error occurs on a connection. The possible errors are:
recv
returns 0
) or TipcConnFlush (when the socket function send
returns -1
)Connection error callbacks usually take measures to re-establish the connection. See TIBCO SmartSockets Utilities for more information on callbacks.
A connection error callback function should not destroy the connection with TipcConnDestroy.
The T_ENTRY declaration specifier is required in the definition of all callback functions as well as their prototypes.
TipcConnErrorCbLookup; see the TIBCO SmartSockets Utilities for information on TutCbDestroy.
This example creates a connection error callback which prints a warning and sets a global flag to indicate that an error has occurred:
T_BOOL my_conn_error_happened = FALSE;/* =========================================================== */
/*..my_conn_error_cb -- connection error callback */
void T_ENTRY my_conn_error_cb(conn, data, arg) T_IPC_CONN conn; T_IPC_CONN_ERROR_CB_DATA data; T_CB_ARG arg;/* not used */
{ TutWarning("Error <%s> occurred on my connection.\n", TutErrNumToStr(data->err_num)); my_conn_error_happened = TRUE; }/* my_conn_error_cb */
/* =========================================================== */
/*...code from calling fragment is below */
if (TipcConnErrorCbCreate(conn, my_conn_error_cb, NULL) == NULL) {
return
; /* error */
}/* Now use the global flag to check for errors. */
msg = TipcConnMsgNext(conn, T_TIMEOUT_FOREVER); if (msg == NULL && my_conn_error_happened) {return
; /* error */
}
TIBCO SmartSockets™ Application Programming Interface Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |