TipcEventCreateSocket create a socket event
T_IPC_EVENT TipcEventCreatSocket(dispatcher
,socket
,check_mode
,event_func
,event_arg
) T_IPC_DISPATCHERdispatcher
; T_INT4socket
; T_IO_CHECK_MODEcheck_mode
; T_IPC_EVENT_FUNCevent_func
; T_PTRevent_arg
;
dispatcher
the dispatcher on which to invoke the event
socket
the socket to wait for availability on
check_mode
the type 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
A new event if successful, NULL
otherwise.
If TipcEventCreateSocket fails, it returns FALSE
and sets the global SmartSockets error number to one of:
TipcEventCreateSocket creates a socket event of type T_IPC_EVENT_SOCKET to be invoked when socket
is available for reading or writing, depending on the value of check_mode
.
When an 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.
TipcEventGetType, TipcEventGetCheckMode, TipcEventGetSocket
This example creates a socket event:
void T_ENTRY socketFunc(T_IPC_EVENT event, T_IPC_EVENT_DATA data, T_PTR arg) { T_IO_CHECK_MODE check_mode; T_INT4 socket; if (!TipcEventGetCheckMode(event, &check_mode)) {
return
; /* error */
} if (!TipcEventGetSocket(event, &socket)) {
return
; /* error */
} if (check_mode == T_IO_CHECK_READ) { read(socket); } else if (check_mode == T_IO_CHECK_WRITE) { write(socket); } } /* =========================================================== *//*...code from main program is below */
read_event = TipcEventCreateSocket(dispatcher, socket, T_IO_CHECK_READ, socketFunc, T_NULL); if (read_event == NULL) {
return
; /* error */
} write_event = TipcEventCreateSocket(dispatcher, socket, T_IO_CHECK_WRITE, socketFunc, 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 |