Network design is not complex. The most important thing is to select a handy software to help us complete our tasks. In this regard, we will introduce the Telnet Tool ActiveX control today. For details about the basic information and usage of this control, refer to the following section.
1. design background
More and more enterprises choose Microsoft-based architecture when building their own WEB sites. Windows, iis web Server, and ASP are widely used. However, many enterprises have a large number of UNIX hosts in their networks. As a result, we often want to access and control UNIX system resources in browsers. For example: you can use a browser to view User processes in a UNIX system, view the network status, or even kill a process. Previously, we could remotely log on to the UNIX host through the Telnet program, enter the user name and password, and enter the command in the command line mode. Through ASP ActiveX control programming, we can also use Telnet protocol to access UNIX hosts. In this way, resources in UNIX systems can be fully utilized in the B/S environment.
2. Functions of the control
The control to be introduced in this article is the Telnet Tool ActiveX control in the PowerTCP Tools control group developed by Dart Communications. It supports development environments such as Visual Studio, ASP, Office 97 (VBA), C ++ Builder, Delphi, and PowerBuilder.
It can manage connections between Telnet, rsh, rexec, and rlogin. It provides methods for establishing, using, and terminating sessions, and supports automatic option negotiation, such as terminal type, echo mode, and window size, users do not have to worry about the protocol implementation details, which greatly simplifies the programming difficulty of using these protocols. The control can communicate with UNIX hosts, routers, terminal servers, and other devices directly through Telnet, and supports indirect Telnet access.
3. ASP programming method for controls
The use of the Telnet Tool ActiveX control is extremely simple. The following describes its main attributes and methods.
TermType attribute: Specifies the terminal type, such as ANSI and VT320, to notify the UNIX host client of the simulated terminal type.
Timeout attribute: When the value is set to 0, the control controls sessions in non-blocking mode. When it is set to a value greater than 0, the control uses the blocking method to control the session. Timeout indicates the Timeout setting, in milliseconds.
State attribute: return the TCP connection status.
Connect Method: create a connection in the following format:
Object. Connect RemoteName [, RemotePort] [, LocalName] [, LocalPort]. RemoteName is the name or IP address of the UNIX host to be connected. RemotePort is the port number of the UNIX host to be connected. The default value is 23, which is the standard telnet port. LocalName and LocalPort are local host names and ports, which can be omitted.
Close method: Close a connection in the format of Object. Close
Send method: Send data after the connection is established. Format:
Object. Send Data. Data is the Data to be sent to the UNIX host.
Serach method: receives the data returned by the UNIX host and searches for the specified end mark in the data stream. The result includes all the returned data until the end mark. If the specified end mark is not obtained within the time specified by Timeout, a Timeout error is generated. Format: Object. Search Data, Token. Data to save the returned results. The Token specifies the end flag string.