TipcConnWriteCbCreate


Name

TipcConnWriteCbCreate — create a write callback in a connection

Synopsis

T_CB TipcConnWriteCbCreate(conn, mt, func, arg) 
T_IPC_CONN conn; 
T_IPC_MT mt; 
T_IPC_CONN_WRITE_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 TipcConnWriteCbCreate fails, it returns NULL and sets the global SmartSockets error number to one of:

Description

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.

Caution

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

See Also

TipcConnWriteCbLookup; see the TIBCO SmartSockets Utilities for information on TutCbDestroy.

Examples

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