5. Explicit description of control mechanism
User Terminal Printing Action & Control Procedure
Negotiate the use of the RCTE option. Once the option is in force the user Telnet follows the following procedure.
-
Read an item from the network.
If the item is data, then print it and go to 1.
If the item is a command, then set the classes and go to 2.
-
If the terminal input buffer is empty, then go to 3, else go to 4.
-
Wait for an item to appear either from the terminal or from the network.
If an item appears from the terminal, then go to 4.
If a data item appears from the network, then print it and go to 3.
If a command appears from the network, then an error has occured.
-
Read an item from the terminal input buffer.
If the item is not a break, then print/skip it and go to 2.
If the item is a break, then print/skip it and go to 1.
Note: Output from the server host may occur at any time, such "spontaneous output" is printed in step 3.
Explanation:
Both Hosts agree to use the RCTE option. After that, the using host (IAC DO RCTE) merely acts upon the controlling (serving) host's commands and does not issue any RCTE commands unless and until it (using host) decides to stop allowing use of the option (by sending IAC DON'T RCTE).
- The using host is synchronized with the server by initially and when ever it returns to step 1 suspending terminal echo printing until it receives a command from the server.
The server may send either output to the terminal printer or a command, and usually sends a both.
The server may send output to the terminal printer either in response to user input or spontaneously. In the former case, the output is processed in step 1. In the latter case, the output is processed in step 3.
Server sends an RCTE command. The command may redefine break and transmission classes, action to be performed on break characters, and action to be performed on text. Each of these independent functions is controlled by separate bits in the <cmd> byte.
A transmission character is one which RECOMMENDS that the using host transmit all text accumulated up to and including its occurrence. (For network efficiency, using hosts are DISCOURAGED (but not prohibited) from sending before the occurrence of a transmission character, as defined at the moment the character is typed).
If the transmission classes bit (bit 4) is on, the two bytes following the two break classes bytes (or immediately following the <cmd> byte, if the break classes bit is not on) will indicate what classes are to be enabled.
If the bit is OFF, the transmission classes remain unchanged. When the RCTE option is first initiated, NO CLASSES are in effect. That is, no character will be considered a transmission character. (As if both TC1 and TC2 are zero.)
A break character REQUIRES that the using host transmit all text accumulated up to and including its occurrence and also causes the using host to stop its print/discard action upon the user's input text, until directed to do otherwise by another IAC SB RCTE <cmd> IAC SE command from the serving host. Break characters therefore define printing units. "Break character" as used in this document does NOT mean Telnet Break character.
If the break classes bit (bit 3) is on, the two bytes following <cmd> will indicate what classes are to be enabled. There are currently nine (9) classes defined, with room for expansion.
If the bit is OFF, the break classes remain unchanged. When the RCTE option is initiated, NO CLASSES are to be in effect. That is, no transmission will take place in the user to server direction until the first break reset command is received by the user from the server.
The list of character classes, used to define break and transmission classes are listed at the end of this document, in the Tables Section.
Because break characters are special, the print/discard action that should be performed upon them is not always the same as should be performed upon the rest of the input text.
For example, while typing a filename to TENEX, I want the text of the filename to be printed (echoed); but I do not want the <escape> (if I use the name completion feature) to be printed.
If bit 1 is ON the break character is NOT to be printed.
A separate bit (bit 2) signals whether or not the text itself should be printed (echoed) to the terminal. If bit 2 = 0, then the text IS to be printed.
Yet another bit (bit 0 - right-most bit) signals whether or not any of the other bits of the command should be checked. If this bit is OFF, then the command should be interpreted to mean "continue whatever echoing strategy you have been following, using the same break and transmission classes."
-
The user Telnet now checks the terminal input buffer, if it contains data it is processed in step 4, otherwise the user Telnet waits in step 3 for further developments.
-
The user Telnet waits until either the human user enters some data in which case Telnet proceeeds to step 4, or an item is received from the network. If the item from the network is data it is spontaneous output and is printed, Telnet then continues to wait. If the item from the network is a command then an error has occured. In this case the user Telnet may attempt to resynchronize the use of RCTE as indicated below.
-
Items from the terminal are processed with printing controlled by the settings of the latest break reset command. When a break character is processed, the cycle of control is complete and action re-commences at step 1.
Input from the terminal is (hopefully) buffered into units ending with a transmission or break character; and echoing of input text is suspended after the occurrence of a break character and until receipt of a break reset command from the serving host. The most recent break reset command determines the break actions.
In summary, what is required is that for every break character sent in the user to server direction there be a break reset command sent in the server to user direction. The user host initially has no knowledge of which characters are break characters and so starts in a state that assumes that there are no break characters and also that no echoing is to be provided. The server host is expected to send a break reset command to establish the break classes and the echoing mode before it receives any data from the user.
Synchronization and Resynchronization:
The serving and using hosts must carefully synchronize break reset commands with the transmission of break characters. Except at the beginning of an interaction, the serving host may only send a break reset command in response to the Using host's having sent a break character as defined at that time. This should establish a one-to-one correspondence between them. (A <cmd> value of zero, in this context, is interpreted as a break classes reset to the same class(es) as before.) The break reset command may be preceded by terminal output.
The re-synchronization of the break characters and the break reset commands is done via the exchange of the Telnet signal Abort Output (AO) in the server to user direction and the SYNCH in the user to server direction.
Suppose the server wants to resynchronize the break characters and the break reset commands.
a. The server should be sure all output to the terminal has been printed by using, for example, the Timing Mark Option.
b. The server sends the AO signal.
c. The user receives the AO signal. The user flushes all user to server data wheather it has been echoed or not. The user sends a SYNCH to the server. [The SYNCH consists of the Telnet Data Mark (DM) and the host-to-host interrupt (INS).] The user now enters the initial state at step 1.
d. The server receives the SYNCH and flushes any data preceeding the DM (as always). The server now sends a break reset command. (Actually the break reset command could be sent at any time following the AO.)
Suppose the user wants to resynchronize the break characters and the break reset commands.
a. The user should discard all user to server data wheather it has been echoed or not.
b. The user sends the AO signal. The user now enters the algorithm at step 1.
c. The server receives the AO signal. The server discards all data buffered but not yet sent to the user. The server sends a SYNCH to the user. The server sends a break reset command to the user.
Notes and Comments:
Even-numbered commands, greater than zero, are in error, since they will have the low-order bit off. The command should be interpreted as equal to zero, which means that any classes reset bytes ([TC1 TC2] [BC1 BC2]) will be in error. (The IAC SE, at the end of the command, eliminates any parsing problems due to this error.)
Serving hosts will generally instruct using hosts not to echo break characters, even though it might be alright to echo most break characters. For example, <cr> is usually a safe character to echo but <esc> is not. TENEX Exec is willing to accept either, during filename specification. Therefore, the using host must be instructed not to echo any break characters.
This is generally a tolerable problem, since the serving host has to send an RCTE command at this point, anyhow. Adding an echo for the break character to the message will not cause any extra network traffic.
The RCTE Option entails a rather large overhead. In a true character-at-a-time situation, this overhead is not justified. But on the average, it should result in significant savings, both in network traffic and host wake-ups.
Buffering Problems and Transmission vs. Printing Constraints:
There are NO mandatory transmission constraints. The using host is allowed to send a character a time, though this would be a waste of RCTE. The transmission classes commands are GUIDELINES, so deviating from them, as when the user's buffer gets full, is allowed.
Additionally, the using host may send a break class character, without knowing that it is one (as with type-ahead).
If the user implementation is clever it may send the user entered data to the server before it is actually needed. This type ahead data may contain break characters.
Assume that only space is a break character (that is the last break reset command specified print up to and including the break characters and set the break classes to class 9). Suppose the user had typed abc<space>def<esc>ghi<cr>. The user side RCTE could send it all to the server, but it could print only abc<space>, and would have to buffer def<esc>ghi<cr> at least until a break reset command was received from the server. That break reset command could change the break ckasses requiring rescanning the buffered string.
For example suppose the break reset command set the break characters to class 5 and the action to print up to but not including the break character. The user RCTE could then print "def" and discard the <esc>, but whould have to continue to buffer the ghi<cr>.
The problem with buffering occurs when printing on the user's terminal must be suspended, after the user has typed a currently valid break character and until a break reset command is received from the serving host. During this time, the user may be typing merrily along. The text being typed may be SENT, but may not yet be PRINTED.
The more common problem of filling the transmission buffer, while awaiting a host to host allocate from the serving host, may also occur, but this problem is well known to implementors and in no way special to RCTE.
In any case, when the buffer does fill and further text typed by the user will be lost, the user should be notified (perhaps by ringing the terminal bell).
Text should be buffered by the using host until the user types a character which belongs to the transmission class in force at the moment the character is typed.
Transmission class reset commands may be sent by the serving host at any time. If they are frequently sent separate from break class reset commands, it will probably be better to exit from RCTE and enter regular character at a time transmission.
It is not immediately clear what the using host should do with currently buffered text, when a transmission classes reset command is received. The buffering is according to the previous transmission classes scheme.
The using host clearly should not simply wait until a transmission character (according to the new scheme) is typed.
Either the buffered text should be rescanned, under the new scheme;
Or the buffered text should simply be sent as a group. This is the simpler approach, and probably quite adequate.
It is possible to define NO BREAK CHARACTERS except Telnet commands (IAC ...). This seems undesirable and should not be done.
If this situation were to occur the using host should send a Telnet command to allow the server to know when he may reset the break classes, but the mechanism is awkward and this case should be avoided.