HP-UX SNAplus2 MS Programmer's Guide
Writing MS Applications
Scheduling Asynchronous Events
Chapter 2 43
generate any subsequent callbacks. For more information about
callbacks, see “The Callback Routine Specified on the ms_async Entry
Point”.
The 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 any 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 then must 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 SNA event handler.
Step 4. To call the SNA event handler, add the following function call to your
code:
SNA_EVENT_FD();
The SNA_EVENT_FD call has no error return values.
Signal-Based Scheduling Mode
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.