TipcConnProcessCbCreate


Name

TipcConnProcessCbCreate — create a process callback in a connection

Synopsis

T_CB TipcConnProcessCbCreate(conn, mt, func, arg) 
T_IPC_CONN conn; 
T_IPC_MT mt; 
T_IPC_CONN_PROCESS_CB_FUNC func; 
T_CB_ARG arg; 

Arguments

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

Return Values

New callback if successful, NULL otherwise.

Diagnostics

If TipcConnProcessCbCreate fails, it returns NULL and sets the global SmartSockets error number to one of:

Description

TipcConnProcessCbCreate creates a process callback in a connection. These callbacks are called by TipcConnMsgProcess to perform the normal processing of a message, such as storing numeric data values and then acting on the variables. See the TIBCO SmartSockets Utilities for more information on callbacks.

A process callback is usually created for a specific message type and connection. If the message type is null, then a global process callback is created for all message types on that connection.

Caution

The T_ENTRY declaration specifier is required in the definition of all callback functions as well as their prototypes.

See Also

TipcConnDefaultCbCreate, TipcConnMsgProcess, TipcConnProcessCbLookup; see the TIBCO SmartSockets Utilities for information on TutCbDestroy.

Examples

This example creates a global connection process callback that writes all processed messages to a message file:

void T_ENTRY my_conn_process_cb(conn, data, arg) 
T_IPC_CONN conn; 
T_IPC_CONN_PROCESS_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_process_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 process callback */ 
if (TipcConnProcessCbCreate(conn, NULL, my_conn_process_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