BSD Sockets Interface Programmer's Guide
Chapter 3 81
Advanced Topics for Stream Sockets
Sending and Receiving Out-of-band Data
Sending and Receiving Out-of-band
Data
This option is not supported for UNIX Domain (AF_UNIX) sockets.
If an abnormal condition occurs when a process is in the middle of
sending a long stream of data, it is useful to be able to alert the other
process with an urgent message. The TCP stream socket implementation
includes an out-of-band data facility. Out-of-band data uses a logically
independent transmission channel associated with a pair of connected
stream sockets. TCP supports the reliable delivery of only one
out-of-band message at a time. The message can be a maximum of one
byte long.
Out-of-band data arrive at the destination node in sequence and in
stream, but are delivered independently of normal data. If the receiver
has enabled the signalling of out-of-band data via the SIOCSPGRP
socket ioctl (see the socket(7) man page), then a SIGURG is
delivered when out-of-band data arrive. If the receiver is selecting for
exceptional conditions on the receiving socket, it will return true to
signal the arrival of out-of-band data. The receiving process can read the
out-of-band message and take the appropriate action based on the
message contents. A logical mark is placed in the normal data stream to
indicate the point at which the out-of-band data were sent, so that data
before the message can be handled differently from data following the
message. Here is a data stream with an out-of-band marker:
For a program to know when out-of-band data are available to be
received, you may arrange the program to catch the SIGURG signal as
follows:
struct sigvec vec;
int onurg();
int pid, s;
/*
** arrange for onurg() to be called when SIGURG is received:
*/
vec.sv_handler = onurg;
vec.sv_mask = 0;
byte stream <----- data oob mark data <--------