HPlogo X25/9000: X.25/9000 Programmer's Guide > Chapter 5  Receiving and Transmitting Out-of-Band Information

Receiving Out-of-Band Events

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

Out-of-band events, such as RESET INDICATION, INTERRUPT, and CLEAR INDICATION packets, occur during typical X.25 VC operation.

When an out-of-band event occurs, X.25 indicates the event by sending a SIGURG signal, and places a description of the event in the out-of-band queue.

WARNING! Applications using X.25 programmatic access should be designed to receive the SIGURG signal and process the information associated with the event. If the process has not attached a signal handler to receive this signal, the signal is ignored. Failure to respond to some out-of-band events (a RESET packet for example) may result in the VC being cleared by the network provider.

Out-of-band events are placed in the out-of-band queue regardless of whether a signal handler has been installed. While it is possible to program applications to periodically examine the out-of-band queue to obtain any out-of-band events that have occurred, it is not recommended.

Signal Reception

Signal handling under HP-UX is controlled by the signal(2), sigsetmask(2), and sigvector(2) system calls. These system calls are described in your HP-UX man pages. The sigvector() system call allows you to specify a signal handler (signal catcher) to process signals when they arrive.

The following example shows how a signal handler may be installed to receive the SIGURG signal:

struct sigvec vec;
int onurg();
int pid, s;

/*
** arrange for the onurg() signal handler to be called
when SIGURG is received:
*/
vec.sv_handler = onurg;
vec.sv_mask; = 0
vec.sv_onstack = 0;
if (sigvector(SIGURG, &vec, 0) < 0) {
perror("sigvector(SIGURG)");
}

In addition to installing the signal handler, you must also call ioctl(SIOCSPGRP) to ensure that the SIGURG signal is delivered upon receipt of the out-of-bound data as shown in the code example below. Refer to the s ocket(7) man page for more information about the ioctl(SIOCSPGRP) call.

setsigskt(s)
int s;
{
int pid;
/* enables the current process to receive SIGURG
* when the socket has urgent data;
*/
pid = getpid();
/* Note that specifying the process id in the next ioctl()
* means that only this process shall receive the SIGURG
* signal.
If (-1)*getpid() is used instead,
the entire

*
process group (including
* parents and children) will receive the SIGURG signal.
*/
if (ioctl(s, SIOCSPGRP, (char *) &pid) < 0) {
perror ("ioctl(SIOCSPGRP)");
}

Once installed, the signal handler is called whenever the specified signal arrives. While a signal handler is executing, additional signals of the same type are blocked from arrival. All signals sent by a socket should be handled by the process which is controlling the VC. This ensures process continuity.