TipcEventCreateConn


Name

TipcEventCreateConn — create a connection event

Synopsis

T_IPC_EVENT TipcEventCreatConn(dispatcher, conn, check_mode, event_func, 
event_arg) 
T_IPC_DISPATCHER dispatcher; 
T_IPC_CONN conn; 
T_IO_CHECK_MODE check_mode; 
T_IPC_EVENT_FUNC event_func; 
T_PTR event_arg; 

Arguments

dispatcher — the dispatcher on which to invoke the connection event

conn — the connection to wait for availability on

check_mode — the kind of availability to wait on: T_IO_CHECK_READ or T_IO_CHECK_WRITE

event_func — the function to be invoked

event_arg — an optional argument to pass to the event_func

Return Values

A new event if successful, NULL otherwise.

Diagnostics

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

Description

TipcEventCreateConn creates a connection event of type T_IPC_EVENT_CONN to be invoked when conn is available for reading or writing, depending on the value of check_mode.

Caution

When a connection event is created or destroyed from a thread other than the thread dispatching the events, a user event is added to the dispatcher to perform the actual creation or destruction. To ensure that event data, such as a socket or a connection, is not destroyed before the event is removed from the dispatcher, create a user event to destroy the event and to perform any necessary cleanup. See the example for TipcEventCreate.

See Also

TipcEventGetType, TipcEventGetCheckMode, TipcEventGetConn

Examples

This example creates a connection event:

void T_ENTRY connFunc(T_IPC_EVENT event, T_IPC_EVENT_DATA data, 
                      T_PTR arg) 
{ 
  T_IO_CHECK_MODE check_mode; 
  T_IPC_CONN conn; 
 
  if (!TipcEventGetCheckMode(event, &check_mode)) { 
    return;  /* error */ 
  } 
 
   if (!TipcEventGetConn(event, &conn)) { 
    return;  /* error */ 
  } 
 
  if (data->check_mode == T_IO_CHECK_READ) { 
    TipcConnMainLoop(data->conn, 0.25); 
  } 
  else if (data->check_mode == T_IO_CHECK_WRITE) { 
    TipcConnFlush(data->conn); 
  } 
} 
 
/* =========================================================== */ 
/*...code from main program is below */ 
 
read_event = TipcEventCreateConn(dispatcher, conn, 
T_IO_CHECK_READ, 
                                 connFunc, T_NULL); 
if (read_event == NULL) { 
  return;  /* error */ 
} 
 
write_event = TipcEventCreateConn(dispatcher, socket, 
T_IO_CHECK_WRITE, 
                                  connFunc, T_NULL); 
if (write_event == NULL) { 
  return;  /* error */ 
} 

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