HP X.25/9000 Programmer's Guide

72 Chapter5
Receiving and Transmitting Out-of-band Information
Building a Signal Handler
Step 3. Get any out-of-band events which may have arrived while the signal
handler was executing.
No more than one signal of the same type can be blocked while a signal
handler is operating. If a second signal arrives, the first is lost. To make
sure that no data is lost, once it’s executed the signal handler should get
all of the data in the out-of-band queue (i.e., issue recv(MSG_OOB) calls
until a 0 is returned).
Step 4. Return execution control to the main process.
Normal operation of the program is halted while the signal handler is
executing. When it returns, processing resumes at the point at which it
was interrupted.
Example of an X.25 Signal Handler
onurg() is a routine that handles out-of-band events in the client
program.
NOTE For the sake of simplicity, this example assumes only one socket. If you
have more than one socket, you can have the handler poll each socket in
turn to see if OOB information has arrived.
#define MAX_EVENT_SIZE 34
/* Define maximum OOB message size: 32 + 1 byte for the
* packet type + 1 byte for the total event size */
/* Definitions for Out-of-Band events (OOB_INTERRUPT,
* OOB_VC_CLEAR, OOB_VC_RESET and others) are stored in
* x25.h
*/
onurg(skt)
int skt
{
int error, s, n, buflen;
unsigned buf[MAX_EVENT_SIZE];
while (1)
{
buflen = MAX_EVENT_SIZE;
if ((n = recv(skt, buf, buflen, MSG_OOB)) < 0)
{
perror(”recv MSG_OOB”)
36960-90061.bk Page 72 Friday, November 10, 2000 3:42 PM