Many transport layers have the concept of out-of-band data, which is sometimes called expedited data. The
idea is that something important occurs at one end of a connection and that end wants to tell its peer quickly.
By "quickly" we mean that this notification should be sent before any "normal" (sometimes called "in-band") data that is already queued to be sent, and should be sent regardless of any flow control or blocking issues. That is, out-of-band data is considered higher priority than normal data. Instead of using two connections between the client and server, out-of-band data is mapped onto the existing connection.
TCP does not have true out-of-band data. Instead, TCP provides an urgent mode. Assume a process has written N bytes
of data to a TCP socket and that data is queued by TCP in the socket send buffer, waiting to be sent to the peer.
The process now writes a single byte of out-of-band data, containing the ASCII character a, using the send function
and the MSG_OOB flag.
send(fd, "a", 1, MSG_OOB);
TCP places the data in the next available position in the socket send buffer and sets its urgent pointer for this
connection to be the next available location.
We now show a simple example to illustrate the following two features of the out-of-band mark:
The out-of-band mark always points one beyond the final byte of normal data. This means that, if the out-of-band data
is received inline, sockatmark returns true if the next byte to be read is the byte that was sent with the MSG_OOB flag.
Alternately, if the SO_OOBINLINE socket option is not enabled, then sockatmark returns true if the next byte of data
is the first byte that was sent following the out-of-band data.
A read operation always stops at the out-of-band mark. That is, if there are 100 bytes in the socket receive buffer,
but only 5 bytes until the out-of-band mark, and the process performs a read asking for 100 bytes, only the 5 bytes
up to the mark are returned. This forced stop at the mark is to allow the process to call sockatmark to determine if
the buffer pointer is at the mark.