TipcSrvDestroyCbCreate


Name

TipcSrvDestroyCbCreate — create a server destroy callback

Synopsis

T_CB TipcSrvDestroyCbCreate(func, arg) 
T_IPC_SRV_DESTROY_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 TipcSrvDestroyCbCreate fails, it returns NULL and sets the global SmartSockets error number to one of:

Description

TipcSrvDestroyCbCreate creates a server destroy callback. These callbacks are called when an RTclient destroys its connection to RTserver. Server destroy callbacks are useful for breaking any dependencies that RTclient has on being connected to RTserver. See the TIBCO SmartSockets Utilities reference for more information on callbacks.

Server create callbacks are the opposite of server destroy callbacks. Server create callbacks can be used to perform processing when an RTclient creates a connection to RTserver. See TipcSrvCreateCbCreate for more information on server create callbacks.

When the callback function is called, the second function argument contains the callback data (C type T_IPC_SRV_DESTROY_CB_DATA). The fields old_conn_status and new_conn_status (both have C type T_IPC_SRV_CONN_STATUS) in this callback data can be used to determine the previous and current status of the connection to RTserver. See TipcSrvCreate on automatic creation of connections and warm connections to RTserver.

Caution

The first argument passed to func is the current connection to RTserver. This argument is null if there is currently no connection to RTserver.

A server destroy callback should not call any of the TipcSrv* functions that attempt to automatically connect to RTserver, as this would cause the server destroy callback to reconnect to RTserver.

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

See Also

TipcSrvCreateCbCreate, TipcSrvDestroyCbLookup; see the TIBCO SmartSockets Utilities for information on TutCbDestroy.

Examples

This example shows how to use server destroy (and server create) callbacks to mix Motif and a connection to RTserver:

/*..my_xt_func -- read and process data from RTserver */ 
void my_xt_func(client_data, source, id) 
XtPointer client_data; /* not used */ 
int *source; /* not used */ 
XtInputId *id; /* not used */ 
{ 
  TipcSrvMainLoop(0.0); 
} /* my_xt_func */ 
 
/*..my_server_destroy_cb -- unhook RTserver connection from Motif */ 
void T_ENTRY my_server_destroy_cb(conn, data, arg) 
T_IPC_CONN conn; 
T_IPC_SRV_DESTROY_CB_DATA data; 
T_CB_ARG arg; /* really (XtInputId *) */ 
{ 
  XtInputId *id_ptr = (XtInputId *)arg; 
 
  if (*id_ptr != NULL) { 
    XtRemoveInput(*id_ptr); 
 
    /* clear out id_ptr so that we don’t try to remove the */ 
    /* same Xt ID twice */ 
    *id_ptr = NULL; 
  }  
 
} /* my_server_destroy_cb */ 
 
/*..my_server_create_cb -- hook RTserver connection into Motif */ 
void T_ENTRY my_server_create_cb(conn, data, arg) 
T_IPC_CONN conn; 
T_IPC_SRV_CREATE_CB_DATA data; 
T_CB_ARG arg; /* not used */ 
{ 
  T_INT4 source; 
  static XtInputId my_id; /* permanent storage */ 
 
  if (!TipcSrvGetXtSource(&source)) { 
    return;  /* error */ 
  }  
 
  /* create Xt input callback when data available from the */ 
  /* connection to RTserver */ 
  my_id = XtAppAddInput(app_context, 
                       (int)source, 
#ifdef T_OS_VMS 
                        NULL, 
#else 
                        (XtPointer)XtInputReadMask, 
#endif 
                        my_xt_func, 
                        NULL); 
 
  /* create server destroy callback to remove Xt input callback */ 
  if (TipcSrvDestroyCbCreate(my_server_destroy_cb, &my_id) == NULL) 
{ 
    return;  /* error */ 
  }  
 
} /* my_server_create_cb */ 
 
/* =========================================================== */ 
/*...code from main program is below */ 
 
/* NOTE: this can only be used if Motif is initialized before */ 
/* the process will connect to RTserver */ 
 
if (TipcSrvCreateCbCreate(my_server_create_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