TipcSrvTraverseCbCreate


Name

TipcSrvTraverseCbCreate — create a server names traverse callback

Synopsis

T_CB TipcSrvTraverseCbCreate(func, arg) 
T_IPC_SRV_TRAVERSE_CB_FUNC func; 
T_CB_ARG arg; 

Arguments

func — callback function

arg — user-defined argument to pass to func

Return Values

New callback if successful, NULL otherwise.

Diagnostics

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

Description

TipcSrvTraverseCbCreate creates a callback that is called when an RTclient traverses through the Server_Names list. This callback is called for each server name in the list until either:

This callback is invoked by TipcSrvCreate, and is called before an attempt to connect to the RTserver currently being traversed. You can install the callback before or after connecting to the RTserver. See the TIBCO SmartSockets Utilities reference for more information on callbacks. See Server Names Traverse Callbacks for information on the data structure for this callback.

When the callback function is called, the second function argument contains the callback data (C type T_IPC_SRV_TRAVERSE_CB_DATA), which includes the fields stop_traverse and server_name. The stop_traverse field, when set to T_TRUE, causes the process to stop traversing the Server_Names list and causes TipcSrvCreate to fail. The server_name field contains the current server name that is being traversed in the list.

When an error occurs, this callback is called after the server reconnect delay occurs. Set the Server_Reconnect_Delay option to a low value if you want this callback to perform the initial delay.

Caution

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

See Also

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

Examples

This example shows an application that creates a server names traverse callback used to print a message for each server name in the Server_Names list. It stops traversing the Server_Names list if a successful connection is made or connection attempts fail for the first three servers in the list:

#include <rtworks/ipc.h> 
 
/* ===============================================================*/ 
/* ..my_server_traverse_cb - server name traversal callback */ 
void T_ENTRY my_server_traverse_cb 
( 
 T_IPC_CONN conn, 
 T_IPC_SRV_TRAVERSE_CB_DATA data, 
 T_CB_ARG arg 
) 
{ 
  T_INT4 *count = (T_INT4 *)arg; 
 
  TutOut("Inside my_server_traverse_cb: server_name = %s\n",  
        data->server_name); 
 
  /* stop trying at 3 servers */ 
  if(*count >= 3) { 
    TutWarning("Setting stop flag.\n"); 
    data->stop_traverse = T_TRUE; 
  } 
  *count += 1; 
} 
 
/* ===============================================================*/ 
/* ..main - main program */ 
int main(int argc, char **argv) { 
 
  T_INT4 trav_count = 0; 
 
  /*  create a callback to be called when traversing the server names list */ 
  if (TipcSrvTraverseCbCreate(my_server_traverse_cb,  
            (T_CB_ARG)&trav_count) == T_NULL) { 
    return;  /* error */; 
  } 
 
  TipcSrvCreate(T_IPC_SRV_CONN_FULL); 
 
}  /* main */ 

TIBCO SmartSockets™ Application Programming Interface
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com