Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 407

Programming actionscript 3.0
Table of Contents

Advertisement

public function Telnet(server:String, port:int, output:TextArea)
{
serverURL = server;
portNumber = port;
ta = output;
socket = new Socket();
socket.addEventListener(Event.CONNECT, connectHandler);
socket.addEventListener(Event.CLOSE, closeHandler);
socket.addEventListener(ErrorEvent.ERROR, errorHandler);
socket.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
socket.addEventListener(ProgressEvent.SOCKET_DATA, dataHandler);
Security.loadPolicyFile("http://" + serverURL + "/crossdomain.xml");
try
{
msg("Trying to connect to " + serverURL + ":" + portNumber + "\n");
socket.connect(serverURL, portNumber);
}
catch (error:Error)
{
msg(error.message + "\n");
socket.close();
}
}
Writing data to a socket
To write data to a Socket connection, you call any of the write methods in the Socket class
(such as
writeBoolean()
flush the data in the output buffer using the
written to the socket connection using the
as a parameter and sends it to the output buffer. The
follows:
public function writeBytesToSocket(ba:ByteArray):void
{
socket.writeBytes(ba);
socket.flush();
}
This method gets called by the
,
,
writeByte()
writeBytes()
flush()
writeBytes()
sendCommand()
, or
writeDouble()
method. In the Telnet server, data is
method which takes the byte array
writeBytesToSocket()
method of the main application file.
Example: Building a Telnet client
), and then
method is as
407

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents