Dart Telnet Control
Telnet Object
Members 
Description
Use the Telnet Control to manage Telnet, Rsh, Rexec and Rlogin connections. This control simplifies the process of using these protocols by providing methods to establish, use, and terminate sessions. By default, communications block execution of your program; however, you can enable non-blocking use for applications using event-driven communications. Option negotiation automatically defaults to a standard set, but complete control of option negotiation is supported.
Remarks

Telnet applications fall into two primary classes:

The following steps illustrate the ease of use of the Telnet Control:

  1. Connect to the Telnet server with the Connect method.
  2. Send data to the remote host with the Send method.
  3. Receive and process data from the remote host with the Receive or Search methods. These methods receive data in slightly different ways, depending upon your requirements.
  4. Close the connection with the Close method.

Protocol Overview
Telnet is a data communications protocola set of rules for communications between computers. Telnet stands for Telecommunications Network Protocol. Telnet communication works between different types of computers and operating systems because the protocol is the same for all systems. Telnet is often used for remote loginaccessing one computer from another. A typical Telnet application would use the Telnet protocol to move data between a terminal emulator and a UNIX server (host).

Many host computers support the Telnet protocol. The main use is online terminal communications; you can use Telnet to log in to a remote computer and issue commands just as if you were at the remote computer itself. You can also use Telnet to access remote databases, control other computers, distribute work among multiple computers, and remotely execute many applications.

Telnet is similar to TCP; in fact, it is built upon it. Telnet provides additional features that make it an upper-layer protocol. Using Telnet, both ends of a connection send data to each other. Typically, a terminal sends commands to a host, and the host responds with messages or data. For example, a user at a terminal may type "help" and the host may respond with "Type a command to get help on".

Telnet provides option negotiation as a method for establishing conventions between two computers. During a session, either computer may send the other a command, requesting or volunteering a specific option. A typical option is echoing. The process of option negotiation determines if either computer will support echoing.

Telnet Connections
Connections are made on a port, which is a method of distinguishing multiple communications on a single computer. Most Telnet connections are made to port 23, the standard Telnet port.

To make a connection you must specify a port and host name or address to connect to. All computers on a network have an IP address, a number that distinguishes them from other computers. All IP addresses have the following same format:

nnn.nnn.nnn.nnn

where each nnn is a number from 0 to 255 (except for the first n, which may be from 0 to 247).

A typical IP address might be 129.229.1.2. Most networks also support computer names, where the network will translate a name (such as "server3") into an IP address.

Network Virtual Terminal
The Network Virtual Terminal (NVT) is a concept Telnet uses to represent both computers in a connection. The NVT is an imaginary character-based device with a keyboard and a printer (input and output). Incoming data goes to the printer, and input from the keyboard goes to the other end of the Telnet connection. Both ends of a Telnet connection must support the concept of an NVT.

The NVT supports the 7-bit character set known as NVT ASCII. NVT ASCII is the same as normal ASCII text, except that only 7 bits represent the character. The eighth high bit of the byte must be set to 0. In NVT ASCII, an end of line is represented by a two-character sequence CR, LF (carriage return, linefeed).

Both ends of a Telnet connection map their own terminal device characteristics to and from the NVT. For example, a program must change all 8-bit ASCII characters to the NVT character set. The NVT is intended to strike a balance between being overly restrictive (not providing some computers a rich enough vocabulary for mapping into their local character sets) and being overly inclusive (penalizing users with modest terminals).

Please refer to RFC 854 for more information on the NVT.

Binary Data
PowerTCP provides full support for binary data transmission. The Send method applies the following basic Telnet encoding rules:

Every byte of value 255 (IAC) is doubled up into a two-byte (255, 255) value.

Every byte of value 13 (CR) not followed by a byte of value 10 (LF) is transformed into a two-byte (13, 0) value.

Suboption negotiation strings sent by the SendCommand method provide a similar encoding for the IAC. For all data received, the reciprocal transformation takes place within the Telnet Control. This mechanism, established by RFC 854, enables the transmission of 8-bit binary data over a single Telnet channel.

Option Negotiation
Option negotiation is the process of two computers agreeing on what features they will or will not provide. Each computer may send a command to the other, and each may respond to commands. A typical option negotiation session may occur as follows (although over 40 different options might be negotiated):

Computer A Computer B
1. I will echo back what you send to me.
2. OK, Do echo back what I send to you.
3. Do suppress goaheads.
4. No, I won't suppress goaheads.
5. Don't suppress goaheads.
6. OK, I won't suppress goaheads.

Either computer may initiate option negotiation. One computer may request that the other computer support or not support an option, or that it will or won't support an option. The other computer may then respond that it will or won't support an option, or request that the other computer support or not support an option. The following table describes the four option negotiation commands:

Command Description
WILL The sender wants to support the option
WONT The sender will not support the option
DO The sender wants the receiver to support the option
DONT The sender wants the receiver to not support the option

Note If a computer does not want an option supported (WONT/DONT), then the other computer must comply, responding with a DONT or WONT.

Telnet also provides suboption negotiation negotiating details about a specific option. An example is the "terminal type" option. For both computers to decide to support the same terminal type, instead of using a different option for each individual terminal type, use a suboption. A typical suboption negotiation is shown below:

Computer A Computer B
1. I will support different terminal types.
2. OK, Do support different terminal types.
3. OK, send your terminal type suboption.
4. My terminal type suboption is "IBMPC".

Option negotiation and suboption negotiation make Telnet very flexible and adaptable to many different terminal configurations. Refer to the applicable RFCs for more information on Telnet and Telnet option negotiation.

Example
For interactive applications, set the Timeout property to 0 so communications can occur asynchronously as data arrives and as the user types at the keyboard. This VB example shows how to establish a Telnet connection and illustrates the two events that fire to indicate that data needs to be displayed or sent.
Private Sub Command1_Click()
	Telnet1.Timeout = 0
	Telnet1.Connect "catalogue.library.ubc.ca"
End Sub
 
Private Sub Telnet1_Receive()
	Dim s() As Byte
	Dim r As Long
	' when data arrives, receive it and put it into the VT Control
	r = Telnet1.Receive(s)
	If r > 0 Then
		Vt1.Display s
	End If
End Sub
 
Private Sub Vt1_KeyPress(KeyAscii As String)
	' Make sure the user is connected, or else don't
	' display the character
	If Telnet1.State = tcpConnected Then
		' when user hits a key, send the Ascii value to the host
		Telnet1.Send KeyAscii
	End If
End Sub
This VB sample illustrates how to connect to a Telnet server, authenticate, issue a command, receive the reply, and close the connection.
Private Sub Command1_Click()
	Dim Data As String
	Dim Count As Long
	' Set Timeout to 5000 milliseconds to wait on communications
	Telnet1.Timeout = 5000
	' establish a connection to a Telnet server
	Telnet1.Connect "myhostname"
	' wait for login prompt
	Count = Telnet1.Search(Data, "Login: ")
	' send my Username
	Telnet1.Send "user" & vbCrLf
	' wait for the password prompt&ldots;
	Count = Telnet1.Search(Data, "Password:")
	' send my password
	Telnet1.Send "mypassword" & vbCrLf
	' wait for the shell prompt
	Count = Telnet1.Search(Data, "$ ")
	' run a report application
	Telnet1.Send "myreport" & vbCrLf
	' get the report output; terminates with a double line
	Count = Telnet1.Search(Data, vbCrLf & vbCrLf)
	Text1.Text = Data ' put the report into an text box for viewing
	' close the connection
	Telnet1.Close
End Sub
See Also

Telnet Members


Documentation Version 1.9.3.0
© 2020 Dart Communications. All Rights Reserved.
Send comments on this topic