TipcConnWriteCbCreate create a write callback in a connection
T_CB TipcConnWriteCbCreate(conn
,mt
,func
,arg
) T_IPC_CONNconn
; T_IPC_MTmt
; T_IPC_CONN_WRITE_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 TipcConnWriteCbCreate fails, it returns NULL
and sets the global SmartSockets error number to one of:
TipcConnWriteCbCreate creates a write callback in a connection. These callbacks are called when a message is buffered to be sent through a connection’s socket, which occurs in TipcConnMsgSend. Connection write callbacks are useful for message file logging and processing of messages before they are actually sent. See TIBCO SmartSockets Utilities for more information on callbacks.
A write callback is usually created for a specific message type and connection. If the message type is null, then a global write 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.
TipcConnWriteCbLookup; see the TIBCO SmartSockets Utilities for information on TutCbDestroy.
This example creates a global connection write callback that writes all sent messages to a message file:
void T_ENTRY my_conn_write_cb(conn, data, arg) T_IPC_CONN conn; T_IPC_CONN_WRITE_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_write_cb */
/* =========================================================== */
/*...code from calling function is below */
msg_file = TipcMsgFileCreate("my_log.msg", T_IPC_MSG_FILE_CREATE_WRITE); if (msg_file == NULL) {return
; /* error */
}/* global connection write callback */
if (TipcConnWriteCbCreate(conn, NULL, my_conn_write_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 |