TipcConnReadCbCreate create a read callback in a connection
T_CB TipcConnReadCbCreate(conn
,mt
,func
,arg
) T_IPC_CONNconn
; T_IPC_MTmt
; T_IPC_CONN_READ_CB_FUNCfunc
; T_CB_ARGarg
;
conn
connection to create callback for
mt
message type to create callback for (null means global callback)
func
callback function
arg
user-defined argument to pass to func
New callback if successful, NULL
otherwise.
If TipcConnReadCbCreate fails, it returns NULL
and sets the global SmartSockets error number to one of:
TipcConnReadCbCreate creates a read callback in a connection. These callbacks are called when a new message is received from the connection’s socket, which occurs in TipcConnRead. Connection read callbacks are useful for message file logging and preprocessing of messages before the normal processing with TipcConnMsgProcess. See the TIBCO SmartSockets Utilities for more information on callbacks.
A read callback is usually created for a specific message type and connection. If the message type is null, then a global read callback is created for all message types on that connection.
The T_ENTRY declaration specifier is required in the definition of all callback functions as well as their prototypes.
TipcConnReadCbLookup; see the TIBCO SmartSockets Utilities for information on TutCbDestroy.
This example creates a global connection read callback that writes all received messages to a message file:
void T_ENTRY my_conn_read_cb(conn, data, arg) T_IPC_CONN conn; T_IPC_CONN_READ_CB_DATA data; T_CB_ARG arg;/* really (T_IPC_MSG_FILE) */
{ T_IPC_MSG msg = data->msg; T_IPC_MSG_FILE msg_file = arg; if (!TipcMsgFileWrite(msg_file, msg)) {return
; /* error */
} }/* my_conn_read_cb */
/* =========================================================== */
/*...code from calling function is below */
T_IPC_MSG_FILE msg_file; msg_file = TipcMsgFileCreate("my_log.msg", T_IPC_MSG_FILE_CREATE_WRITE); if (msg_file == NULL) {return
; /* error */
}/* global connection read callback */
if (TipcConnReadCbCreate(conn, NULL, my_conn_read_cb, msg_file) == NULL) {return
; /* error */
}
TIBCO SmartSockets™ Application Programming Interface Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |