The Telnet Protocol control enables an application to connect to a Telnet server, which provides an interactive terminal session similar to how character based consoles and terminals work. The user can login, enter commands and interact with applications programmatically or in conjunction with the terminal emulation control.
Initialize
Initialize an instance of the class, loading the networking library and
validating the development license. This method must be called before
any properties are changed or any other methods in this class are called
by the application.
Connect
Establish a connection to the server. Once the connection has been
established, the other methods in the class may be used to exchange data
with the server.
Disconnect
Disconnect from the server and release the memory allocated for that
client session. After this method is called, the client session is no
longer valid.
Reset
Reset the internal state of the component. This can
be useful if your application wishes to discard any settings made by a
user and return that instance of the class to its default state.
Uninitialize
Unload the networking library and release any resources that have been
allocated for the class instance. This method is automatically invoked
when the class instance is disposed or goes out of scope.
Once connected to the Telnet server, any output generated by a program on the server will be sent as data for the client to read. Any input to the program is sent by the client and received and processed by the server. The following methods are used:
Read
Reads any output that has been generated by the program executing on the
server. When the client first connects, the server typically executes a
login program that requests the users authenticate themselves by
entering a user name and password. Once the user has logged in, they are
usually given a command line prompt where they can enter commands to be
executed on the server. If the server closes the connection, the Read
method will indicate that with an error result and the client can
disconnect from the server at that point.
Write
Send data to the Telnet server which will be received as input to the
program. If the local echo option is enabled, then the client is also
responsible for writing the input data to the display device, if there
is one. If local echo is not enabled, the server will automatically echo
back any characters written as data to be read by the client.
Telnet supports a mode of operation where the it is the responsibility of the client to echo any data sent to the server. This is controlled by the LocalEcho property.
LocalEcho
If this property is set to True, it is the responsibility of the client
to echo any data that it is sending to the server. For example, if the
character "A" is sent to the server, the application must also send the
character "A" to whatever interface the user is interacting with, such
as a terminal emulation window. The default mode is for this option to
be disabled, which means that the server will echo back any data that is
sent to it.
The Telnet protocol can be used to connect to a server, log in and execute one or more commands, process the output from those commands and display it to an end-user using a graphical interface. The user never sees or interacts with the actual terminal session. The Telnet interface provides methods which can simplify this kind of application, reducing the amount of code needed to process the data stream returned by the server.
Login
This method is used to automatically log a user in, using the specific
user name and password. This method is specifically designed for UNIX
based servers or Windows servers which emulate the same basic login
sequence.
Search
This method is used to search for a specific character or sequence of
characters in the data stream returned by the server. The control will
accumulate all of the data received up to the point where the character
sequence is encountered. This can be used to capture all of the output
from a command, or search for specific results returned by the command
as it executes on the server.