Software flow control is a method of flow control used in computer , especially RS-232 serial. It uses special codes, transmitted in-band, over the primary communications channel. These codes are generally called XOFF and XON (from "transmit off" and "transmit on", respectively). Thus, "software flow control" is sometimes called "XON/XOFF flow control". This is in contrast to flow control via dedicated Out-of-band data signals — "hardware flow control" — such as RS-232 RTS/CTS.
The ASCII standard does not reserve any control characters for use as XON/XOFF specifically. However, it does provide four generic "device control" characters (DC1 through DC4). The Teletype Model 33 ASR adopted two of these, DC3 and DC1, for use as XOFF and XON, respectively. This usage was copied by others, and is now a de facto standard. The keyboard equivalents of for XOFF, and for XON, also derive from this usage.
|+ XOFF/XON representations in ASCII ! Code ! Meaning ! ASCII ! Decimal ! Hexadecimal ! Keyboard|
For example, imagine a computer sending data to a slow printer. Since the computer is faster at sending data than the printer can print it, the printer falls behind and approaches a situation where it would be overwhelmed by the data. The printer reacts to this situation by sending XOFF to the computer, which temporarily stops sending data. When the printer is again ready to receive more data, it sends XON to the computer, which starts sending data again.
However, software flow control is not without its problems. Sending XOFF requires at least one character time to transmit, and may be queued behind already-transmitted data still in buffers. Hardware signals may be asserted almost instantaneously, and out-of-order.
As the name "software flow control" implies, flow control using this method is usually implemented in software (or at least a higher level of firmware), which can cause further delays in XOFF response. Hardware flow control is typically under the direct control of the transmitting UART, which is able to cease transmission immediately, without the intervention of higher levels.
Finally, since the XOFF/XON codes are sent in-band, they cannot appear in the data being transmitted without being mistaken for flow control commands. Any data containing the XOFF/XON codes thus must be encoder in some manner for proper transmission, with corresponding overhead. This is frequently done with some kind of escape sequence. For printing devices that directly interpret ASCII codes, this is not a large problem, because the XON and XOFF codes use ASCII "device control" code numbers.
XOFF/XON are still sometimes used manually by computer operators, to pause and restart output which otherwise would scrolling off the display too quickly.
Terminal emulator software generally implements XOFF/XON support as a basic function. This generally includes the system console on modern Unix and Linux machines, as well as GUI emulators such as xterm and the Win32 console.
Robust XON is a technique to restart communication, just in case it was stopped by an accidentally received XOFF. The receiving unit sends periodic XON characters when it can receive data, and the line is idle. One common use is by serial printers (like HP LaserJet II) to indicate they are online and ready to receive data. The XON is sent every 1 to 30 seconds depending on the printer's firmware design.