'TELIND' TELNET INTERMEDIARY DAEMON
The purpose of the telind daemon program is to provide resilience for telnet
sessions (usually over an ethernet local area network where Windows PC's
are telnetting to a Unix/Linux host). In the event of the Windows telnet client
program terminating prematurely (by user misuse or failure of the Windows
system in some way), a normal telnet session will be either be 'killed' on the
Unix host or will be stuck 'in limbo' with no means of the 'remote' user
re-connecting to the Unix shell or other process being run on the host.
Telind accomplishes resilience by the following means, which also has the
advantage of always assigning a unique 'terminal number' to the user which can
be used for assignment of temporary files and user-dependent variables:-
1) The telind program 'listens' on a suitably-numbered port for an incoming
tcp/ip connection, in the usual way. The client telnet program simply 'telnets'
to the requisite port number instead of the normal telnet port (23).
2) For each possible incoming connection a separate telind program must be
executing and listening on a unique port number. Since the telind program
consumes no cpu resources whilst awaiting a connection, the only drawback to
this strategy is the extra space used up in the tcp/ip 'stack' structures.
3) When an incoming connection is established telind makes an internal
connection to the 'real' telnet daemon on port 23. The 'handshaking' process
between the telnet client on the PC (or whatever) and the real telnet daemon
then takes place in the normal manner - the telind program simply transparently
passes data back and forth.
4) The telind program recognises the 'end' of the telnet negotiation process
and the start of 'normal' data transfer from the shell program spawned on
the client computer, by inspecting all data packets for the string 'W-R-U'
(abbreviation for 'Who Are You').
5) When the 'W-R-U' string is detected the telind program sends a 'Terminal
Number' to the Unix shell program and internally 'flags' the connection as
active.
6) If the unix shell terminates normally, the internal connection between the
shell and the telind program will be closed before the connection between the
client and telind. The telind program simply 'flags' the telnet connection as
no longer active and closes the connection to the external client. Telind then
awaits another incoming connection.
7) If the external connection from the client to telind closes prematurely,
telind leaves its internal connection to the Unix shell 'open' and awaits a
fresh incoming connection from the external client (which may be from the same,
or any other, PC !).
8) If an incoming connection is effectively a 're-connection', telind firstly
establishes a new temporary connection to the real telnet daemon and allows
the telnet 'handshake' process to take place. However, upon receipt of the
'W-R-U' string, telind 'drops' this temporary connection and reverts to using
the old internal port 23 connection. In this manner, the client is
transparently re-connected to the Unix shell (or other program) which was
left 'in limbo' when the premature external connection failure occurred.
Pictorially:-
Windows PC Telind Telnet Unix
Client ------------------- daemon --------------daemon--------Shell program
port nnnn port 23
Note that a small change must be made to the login shell script (profile) on
the Unix/Linux host, to send the 'W-R-U' string and optionally process the
'terminal number' sent as a reply.