HP-UX SNAplus2 CPI-C Programmer's Guide (June 2003)
Writing CPI-C Applications
HP-UX Considerations
Chapter 296
• Signal-based scheduling mode provides binary compatibility for
existing SNAplus2 Release 4 and SNAplus2 Release 5 applications.
It is not recommended for new applications because support for
signal-based scheduling mode may be discontinued in future versions
of SNAplus2.
Application Scheduling Mode
To receive notification of SNA events in application scheduling mode, the
application accesses the file descriptor on which SNA events arrive. It
can then be notified when SNA work arrives, and call the CPI-C library
(using the Check_For_Completion function) to check for the completion
of outstanding CPI-C calls.
Application scheduling mode assumes that the application is structured
as a main loop consisting of a call to either select() or poll() followed
by code to process event information returned by the select() or poll()
call.
To use application scheduling mode, incorporate the following steps into
your application code:
Step 1. Indicate that you want to use application scheduling mode by adding the
following function call to your code before the first call into any SNA
library:
SNA_USE_FD_SCHED();
The SNA_USE_FD_SCHED() call has no error return values.
Step 2. Add code to obtain and track any changes to the SNA file descriptor. Call
the following function from your code before each call to select() or
poll() that can be used to detect SNA events:
Fd= SNA_GET_FD();
The SNA_GET_FD() call returns an integer value (a C int) that is either a
valid file descriptor or a -1 indicating that no valid SNA file descriptor is
available.
Step 3. If the return is valid, the application must then register for “read” events
on the SNA file descriptor in the select() or poll() call. When an
event is detected, the application must call the Check_For_Completion
function.