User Guide
Example: Building a Telnet client 405
The Telnet application files can be found in the Samples/Telnet folder. The application
consists of the following files:
Telnet socket application overview
The main TelnetSocket.mxml file is responsible for creating the user interface (UI) for the
entire application.
In addition to the UI, this file also defines two methods,
login() and sendCommand(), to
connect the user to the specified server.
The following code lists the ActionScript in the main application file:
import com.example.programmingas3.socket.Telnet;
private var telnetClient:Telnet;
private function connect():void
{
telnetClient = new Telnet(serverName.text, int(portNumber.text), output);
console.title = "Connecting to " + serverName.text + ":" +
portNumber.text;
console.enabled = true;
}
private function sendCommand():void
{
var ba:ByteArray = new ByteArray();
ba.writeMultiByte(command.text + "\n", "UTF-8");
telnetClient.writeBytesToSocket(ba);
command.text = "";
}
File Description
TelnetSocket.mxml The main application file consisting of the MXML
user interface.
com/example/programmingas3/Telnet/
Telnet.as
Provides the Telnet client functionality for the
application, such as connecting to a remote server,
and sending, receiving, and displaying data.