TipcSrvReadCbCreate create a read callback in the connection to RTserver
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 TipcSrvReadCbCreate fails, it returns NULL
and sets the global SmartSockets error number to one of:
TipcSrvReadCbCreate creates a read callback in the connection to RTserver by calling TipcConnReadCbCreate. These callbacks are called when a message is read from the connection to RTserver. See TipcConnReadCbCreate for more information on read callbacks.
TipcSrvReadCbCreate may attempt to automatically create a connection to RTserver. If RTclient has a warm connection to RTserver, TipcSrvReadCbCreate creates a read callback in the warm connection. See TipcSrvCreate on automatic creation of connections and warm connections to RTserver.
The T_ENTRY declaration specifier is required in the definition of all callback functions as well as their prototypes.
TipcConnReadCbCreate, TipcSrvReadCbLookup
This example creates a read callback in the connection to RTserver for TIME messages which compares the current data time to the data time in the message. If the two times differ by more than 100, a warning is printed, which provides a simple way for an RTclient to detect that it is falling behind:
/* =============================================================== */
/*..my_srv_read_cb -- compare TIME message against current time */
void T_ENTRY my_srv_read_cb(conn, data, arg) T_IPC_CONN conn;/* connection to RTserver */
T_IPC_CONN_READ_CB_DATA data; T_CB_ARG arg;/* not used */
{ T_IPC_MSG msg = data->msg; T_REAL8 new_time; if (!TipcMsgSetCurrent(msg, 0)) {return
; /* error */
} if (!TipcMsgNextReal8(msg, &new_time)) {return
; /* error */
}/* compare the new time to the current time */
if (new_time - TutGetCurrentTime() > 100.0) { TutWarning("We appear to be %s seconds behind!\n", TutRealToStr(new_time - TutGetCurrentTime())); } }/* my_srv_read_cb */
/* =========================================================== */
/*...code from main program is below */
mt = TipcMtLookupByNum(T_MT_TIME); if (mt == NULL) {return
; /* error */
} if (TipcSrvReadCbCreate(mt, my_srv_read_cb, NULL) == NULL) {return
; /* error */
}
TIBCO SmartSockets™ Application Programming Interface Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |