TCP is fundamentally stream based. Data placed by the sending process into the operating system's TCP transmit buffer is received by the other end and read by the receiving process in exactly the same order in which it was sent. But what if the sending process detects some exceptional condition and it needs to alert the receiver immediately? Vanilla TCP can't handle this well because all data has equal priority, and the urgent message will have to wait its turn behind all the data sent before it. This is where TCP "urgent" data fits in. This facility, more commonly known as "out-of- band " data, makes it possible, in a limited and highly qualified manner, to send and receive TCP messages that are delivered ahead of the ordinary TCP stream. To illustrate the use of such a facility, consider a terminal-based application that allows the user to queue a stream of long-running commands to be executed on the server. After he issues several commands, and while the server is still chewing through them, the user changes his mind and decides to cancel by hitting the interrupt key. But the commands have already been sent to the server and are in the TCP receive queue waiting for processing. Somehow the client must transmit a cancel signal to the server immediately, without queuing a cancel command behind other normal-priority data. One way to accomplish this is to use TCP urgent data to notify the server to clear its list of pending commands and to ignore commands already received but not yet read. We develop just such an application in the course of this chapter. |