Pacoteflash.net
Classepublic class Socket
HerançaSocket Inheritance EventDispatcher Inheritance Object
Implementa IDataInput, IDataOutput

The Socket class enables code to make socket connections and to read and write raw binary data. It is similar to XMLSocket but does not dictate the format of the received or transmitted data.

The Socket class is useful for working with servers that use binary protocols.

When you use this method , consider the Flash Player security model:

However, in the Adobe Integrated Runtime (AIR), content in the application security sandbox (content installed with the AIR application) are not restricted by these security limitations.

For more information, see the following:

Veja Exemplos



Propriedades Públicas
 PropriedadeDefinido por
  bytesAvailable : uint
[read-only] The number of bytes of data available for reading in the input buffer.
Socket
  connected : Boolean
[read-only] Indicates whether this Socket object is currently connected.
Socket
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  endian : String
Indicates the byte order for the data; possible values are constants from the flash.utils.Endian class, Endian.BIG_ENDIAN or Endian.LITTLE_ENDIAN.
Socket
  objectEncoding : uint
Controls the version of AMF used when writing or reading an object.
Socket
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
Métodos Públicos
 MétodoDefinido por
  
Socket(host:String = null, port:int = 0)
Creates a Socket object.
Socket
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
EventDispatcher
  
Closes the socket.
Socket
  
connect(host:String, port:int):void
Connects the socket to the specified host and port.
Socket
 Inherited
Dispatches an event into the event flow.
EventDispatcher
  
Flushes any accumulated data in the socket's output buffer.
Socket
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
  
Reads a Boolean value from the socket.
Socket
  
Reads a signed byte from the socket.
Socket
  
readBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0):void
Reads the number of data bytes specified by the length parameter from the socket.
Socket
  
Reads an IEEE 754 double-precision floating-point number from the socket.
Socket
  
Reads an IEEE 754 single-precision floating-point number from the socket.
Socket
  
Reads a signed 32-bit integer from the socket.
Socket
  
readMultiByte(length:uint, charSet:String):String
Reads a multibyte string from the byte stream, using the specified character set.
Socket
  
Reads an object from the socket, encoded in AMF serialized format.
Socket
  
Reads a signed 16-bit integer from the socket.
Socket
  
Reads an unsigned byte from the socket.
Socket
  
Reads an unsigned 32-bit integer from the socket.
Socket
  
Reads an unsigned 16-bit integer from the socket.
Socket
  
Reads a UTF-8 string from the socket.
Socket
  
Reads the number of UTF-8 data bytes specified by the length parameter from the socket, and returns a string.
Socket
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
  
Writes a Boolean value to the socket.
Socket
  
writeByte(value:int):void
Writes a byte to the socket.
Socket
  
writeBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0):void
Writes a sequence of bytes from the specified byte array.
Socket
  
Writes an IEEE 754 double-precision floating-point number to the socket.
Socket
  
Writes an IEEE 754 single-precision floating-point number to the socket.
Socket
  
writeInt(value:int):void
Writes a 32-bit signed integer to the socket.
Socket
  
writeMultiByte(value:String, charSet:String):void
Writes a multibyte string from the byte stream, using the specified character set.
Socket
  
writeObject(object:*):void
Write an object to the socket in AMF serialized format.
Socket
  
Writes a 16-bit integer to the socket.
Socket
  
Writes a 32-bit unsigned integer to the socket.
Socket
  
Writes the following data to the socket: a 16-bit unsigned integer, which indicates the length of the specified UTF-8 string in bytes, followed by the string itself.
Socket
  
Writes a UTF-8 string to the socket.
Socket
Eventos
 Evento Descrição Definido por
 Inherited Dispatched when Flash Player or the and AIR application gains operating system focus and becomes active.EventDispatcher
   Dispatched when the server closes the socket connection.Socket
   Dispatched when a network connection has been established.Socket
 Inherited Dispatched when Flash Player loses operating system focus and is becoming inactive.EventDispatcher
   Dispatched when an input/output error occurs that causes a send or load operation to fail.Socket
   Dispatched if a call to Socket.connect() attempts to connect either to a server outside the caller's security sandbox or to a port lower than 1024.Socket
   Dispatched when a socket has received data.Socket
Detalhes da propriedade
bytesAvailablepropriedade
bytesAvailable:uint  [read-only]

The number of bytes of data available for reading in the input buffer.

Your code must access bytesAvailable to ensure that sufficient data is available before trying to read it with one of the read methods.


Implementação
    public function get bytesAvailable():uint
connectedpropriedade 
connected:Boolean  [read-only]

Indicates whether this Socket object is currently connected. A call to this property returns a value of true if the socket is currently connected, or false otherwise.


Implementação
    public function get connected():Boolean
endianpropriedade 
endian:String  [read-write]

Indicates the byte order for the data; possible values are constants from the flash.utils.Endian class, Endian.BIG_ENDIAN or Endian.LITTLE_ENDIAN.

The default value is Endian.BIG_ENDIAN.


Implementação
    public function get endian():String
    public function set endian(value:String):void

Veja também

objectEncodingpropriedade 
objectEncoding:uint  [read-write]

Controls the version of AMF used when writing or reading an object.


Implementação
    public function get objectEncoding():uint
    public function set objectEncoding(value:uint):void

Veja também

Detalhes do construtor
Socket()Construtor
public function Socket(host:String = null, port:int = 0)

Creates a Socket object. If no parameters are specified, an initially disconnected socket is created. If parameters are specified, a connection is attempted to the specified host and port.

Parâmetros
host:String (default = null) — The name of the host to connect to. If this parameter is not specified, an initially disconnected socket is created.
 
port:int (default = 0) — The port number to connect to. If this parameter is not specified, an initially disconnected socket is created.

Eventos
connect:Event — Dispatched when a network connection has been established.
 
ioError:IOErrorEvent — Dispatched when an input/output error occurs that causes the connection to fail.
 
securityError:SecurityErrorEvent — Dispatched if a call to Socket.connect() attempts to connect either to a server outside the caller's security sandbox or to a port lower than 1024. You can work around either problem by using a cross-domain policy file on the server. For more information about policy files for sockets, see the "Flash Player Security" chapter in Programming ActionScript 3.0.

Throws
SecurityError — This error occurs for the following reasons:
  • Local untrusted SWF files cannot communicate with the Internet. You can work around this problem by reclassifying this SWF file as local-with-networking or trusted. This limitation is not set for AIR application content in the application security sandbox.
  • You cannot specify a socket port higher than 65535.
Detalhes do método
close()método
public function close():void

Closes the socket. You cannot read or write any data after the close() method has been called.

The close event is dispatched only when the server closes the connection; it is not dispatched when you call the close() method.

You can reuse the Socket object by calling the connect() method on it again.


Throws
IOError — The socket could not be closed, or the socket was not open.
connect()método 
public function connect(host:String, port:int):void

Connects the socket to the specified host and port. If the connection fails immediately, either an event is dispatched or an exception is thrown: an error event is dispatched if a host was specified, and an exception is thrown if no host was specified. Otherwise, the status of the connection is reported by an event. If the socket is already connected, the existing connection is closed first.

By default, the value you pass for host must be in the same domain and the value you pass for port must be 1024 or higher. For exemplo, a SWF file at adobe.com can connect only to a server daemon running at adobe.com. If you want to connect to a socket on a different host than the one from which the connecting SWF file was served, or if you want to connect to a port lower than 1024 on any host, you must obtain an xmlsocket: policy file from the host to which you are connecting. For more information, see the "Flash Player Security" chapter in Programming ActionScript 3.0.

Parâmetros

host:String — The name of the host to connect to. If no host is specified, the host that is contacted is the host where the calling SWF file resides. If you do not specify a host, use an event listener to determine whether the connection was successful.
 
port:int — The port number to connect to.


Eventos
connect:Event — Dispatched when a network connection has been established.
 
ioError:IOErrorEvent — Dispatched if a host is specified and an input/output error occurs that causes the connection to fail.
 
securityError:SecurityErrorEvent — Dispatched if a call to Socket.connect() attempts to connect to either a server outside the caller's security sandbox or to a port lower than 1024. (This restriction is not placed on AIR content runningin the application security sandbox.) You can work around either problem by using a cross-domain policy file on the server. For more information, see the "Flash Player Security" chapter in Programming ActionScript 3.0.

Throws
IOError — No host was specified and the connection failed.
 
SecurityError — This error occurs for the following reasons:
  • Local untrusted SWF files may not communicate with the Internet. You can work around this by reclassifying the file as local-with-networking or trusted.
  • You cannot specify a socket port higher than 65535.
  • In the HTML page that contains the SWF content, the allowNetworking parameter of the the object and embed tags is set to "none".
flush()método 
public function flush():void

Flushes any accumulated data in the socket's output buffer. Data written by the write methods is not immediately transmitted; it is queued until the flush() method is called.


Throws
IOError — An I/O error occurred on the socket, or the socket is not open.
readBoolean()método 
public function readBoolean():Boolean

Reads a Boolean value from the socket. After reading a single byte, the method returns true if the byte is nonzero, and false otherwise.

Retorna
Boolean — A value of true if the byte read is nonzero, otherwise false.

Throws
EOFError — There is insufficient data available to read.
 
IOError — An I/O error occurred on the socket, or the socket is not open.
readByte()método 
public function readByte():int

Reads a signed byte from the socket.

Retorna
int — A value from -128 to 127.

Throws
EOFError — There is insufficient data available to read.
 
IOError — An I/O error occurred on the socket, or the socket is not open.
readBytes()método 
public function readBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0):void

Reads the number of data bytes specified by the length parameter from the socket. The bytes are read into the specified byte array, starting at the position indicated by offset.

Parâmetros

bytes:ByteArray — The ByteArray object to read data into.
 
offset:uint (default = 0) — The offset at which data reading should begin in the byte array.
 
length:uint (default = 0) — The number of bytes to read. The default value of 0 causes all available data to be read.


Throws
EOFError — There is insufficient data available to read.
 
IOError — An I/O error occurred on the socket, or the socket is not open.
readDouble()método 
public function readDouble():Number

Reads an IEEE 754 double-precision floating-point number from the socket.

Retorna
Number

Throws
EOFError — There is insufficient data available to read.
 
IOError — An I/O error occurred on the socket, or the socket is not open.
readFloat()método 
public function readFloat():Number

Reads an IEEE 754 single-precision floating-point number from the socket.

Retorna
Number

Throws
EOFError — There is insufficient data available to read.
 
IOError — An I/O error occurred on the socket, or the socket is not open.
readInt()método 
public function readInt():int

Reads a signed 32-bit integer from the socket.

Retorna
int — A value from -2147483648 to 2147483647.

Throws
EOFError — There is insufficient data available to read.
 
IOError — An I/O error occurred on the socket, or the socket is not open.
readMultiByte()método 
public function readMultiByte(length:uint, charSet:String):String

Reads a multibyte string from the byte stream, using the specified character set.

Parâmetros

length:uint — The number of bytes from the byte stream to read.
 
charSet:String — The string denoting the character set to use to interpret the bytes. Possible character set strings include "shift_jis", "CN-GB", and "iso-8859-1". For a complete list, see Supported Character Sets.

Note: If the value for the charSet parameter is not recognized by the current system, then Flash Player uses the system's default code page as the character set. For exemplo, a value for the charSet parameter, as in myTest.readMultiByte(22, "iso-8859-01") that uses 01 instead of 1 might work on your development machine, but not on another machine. On the other machine, Flash Player will use the system's default code page.

Retorna
String — A UTF-8 encoded string.

Throws
EOFError — There is insufficient data available to read.
readObject()método 
public function readObject():*

Reads an object from the socket, encoded in AMF serialized format.

Retorna
* — The deserialized object

Throws
EOFError — There is insufficient data available to read.
 
IOError — An I/O error occurred on the socket, or the socket is not open.

Veja também

readShort()método 
public function readShort():int

Reads a signed 16-bit integer from the socket.

Retorna
int — A value from -32768 to 32767.

Throws
EOFError — There is insufficient data available to read.
 
IOError — An I/O error occurred on the socket, or the socket is not open.
readUnsignedByte()método 
public function readUnsignedByte():uint

Reads an unsigned byte from the socket.

Retorna
uint — A value from 0 to 255.

Throws
EOFError — There is insufficient data available to read.
 
IOError — An I/O error occurred on the socket, or the socket is not open.
readUnsignedInt()método 
public function readUnsignedInt():uint

Reads an unsigned 32-bit integer from the socket.

Retorna
uint — A value from 0 to 4294967295.

Throws
EOFError — There is insufficient data available to read.
 
IOError — An I/O error occurred on the socket, or the socket is not open.
readUnsignedShort()método 
public function readUnsignedShort():uint

Reads an unsigned 16-bit integer from the socket.

Retorna
uint — A value from 0 to 65535.

Throws
EOFError — There is insufficient data available to read.
 
IOError — An I/O error occurred on the socket, or the socket is not open.
readUTF()método 
public function readUTF():String

Reads a UTF-8 string from the socket. The string is assumed to be prefixed with an unsigned short integer that indicates the length in bytes.

Retorna
String

Throws
EOFError — There is insufficient data available to read.
 
IOError — An I/O error occurred on the socket, or the socket is not open.
readUTFBytes()método 
public function readUTFBytes(length:uint):String

Reads the number of UTF-8 data bytes specified by the length parameter from the socket, and returns a string.

Parâmetros

length:uint — The number of bytes to read.

Retorna
String

Throws
EOFError — There is insufficient data available to read.
 
IOError — An I/O error occurred on the socket, or the socket is not open.
writeBoolean()método 
public function writeBoolean(value:Boolean):void

Writes a Boolean value to the socket. This method writes a single byte, with either a value of 1 (true) or 0 (false).

Note: Data written by this method is not immediately transmitted; it is queued until the flush() method is called.

Parâmetros

value:Boolean — The value to write to the socket: 1 (true) or 0 (false).


Throws
IOError — An I/O error occurred on the socket, or the socket is not open.

Veja também

writeByte()método 
public function writeByte(value:int):void

Writes a byte to the socket.

Note: Data written by this method is not immediately transmitted; it is queued until the flush() method is called.

Parâmetros

value:int — The value to write to the socket. The low 8 bits of the value are used; the high 24 bits are ignored.


Throws
IOError — An I/O error occurred on the socket, or the socket is not open.

Veja também

writeBytes()método 
public function writeBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0):void

Writes a sequence of bytes from the specified byte array. The write operation starts at the position specified by offset.

If you omit the length parameter the default length of 0 causes the method to write the entire buffer starting at offset.

If you also omit the offset parameter, the entire buffer is written.

If offset or length is out of range, they are adjusted to match the beginning and end of the bytes array.

Note: Data written by this method is not immediately transmitted; it is queued until the flush() method is called.

Parâmetros

bytes:ByteArray — The ByteArray object to write data from.
 
offset:uint (default = 0) — The zero-based offset into the bytes ByteArray object at which data writing should begin.
 
length:uint (default = 0) — The number of bytes to write. The default value of 0 causes the entire buffer to be written, starting at the value specified by the offset parameter.


Throws
IOError — An I/O error occurred on the socket, or the socket is not open.

Veja também

writeDouble()método 
public function writeDouble(value:Number):void

Writes an IEEE 754 double-precision floating-point number to the socket.

Note: Data written by this method is not immediately transmitted; it is queued until the flush() method is called.

Parâmetros

value:Number — The value to write to the socket.


Throws
IOError — An I/O error occurred on the socket, or the socket is not open.

Veja também

writeFloat()método 
public function writeFloat(value:Number):void

Writes an IEEE 754 single-precision floating-point number to the socket.

Note: Data written by this method is not immediately transmitted; it is queued until the flush() method is called.

Parâmetros

value:Number — The value to write to the socket.


Throws
IOError — An I/O error occurred on the socket, or the socket is not open.

Veja também

writeInt()método 
public function writeInt(value:int):void

Writes a 32-bit signed integer to the socket.

Note: Data written by this method is not immediately transmitted; it is queued until the flush() method is called.

Parâmetros

value:int — The value to write to the socket.


Throws
IOError — An I/O error occurred on the socket, or the socket is not open.

Veja também

writeMultiByte()método 
public function writeMultiByte(value:String, charSet:String):void

Writes a multibyte string from the byte stream, using the specified character set.

Note: Data written by this method is not immediately transmitted; it is queued until the flush() method is called.

Parâmetros

value:String — The string value to be written.
 
charSet:String — The string denoting the character set to use to interpret the bytes. Possible character set strings include "shift_jis", "CN-GB", and "iso-8859-1". For a complete list, see Supported Character Sets.

Veja também

writeObject()método 
public function writeObject(object:*):void

Write an object to the socket in AMF serialized format.

Note: Data written by this method is not immediately transmitted; it is queued until the flush() method is called.

Parâmetros

object:* — The object to be serialized.


Throws
IOError — An I/O error occurred on the socket, or the socket is not open.

Veja também

writeShort()método 
public function writeShort(value:int):void

Writes a 16-bit integer to the socket. The bytes written are as follows:

(v >> 8) & 0xff v & 0xff

The low 16 bits of the parameter are used; the high 16 bits are ignored.

Note: Data written by this method is not immediately transmitted; it is queued until the flush() method is called.

Parâmetros

value:int — The value to write to the socket.


Throws
IOError — An I/O error occurred on the socket, or the socket is not open.

Veja também

writeUnsignedInt()método 
public function writeUnsignedInt(value:uint):void

Writes a 32-bit unsigned integer to the socket.

Note: Data written by this method is not immediately transmitted; it is queued until the flush() method is called.

Parâmetros

value:uint — The value to write to the socket.


Throws
IOError — An I/O error occurred on the socket, or the socket is not open.

Veja também

writeUTF()método 
public function writeUTF(value:String):void

Writes the following data to the socket: a 16-bit unsigned integer, which indicates the length of the specified UTF-8 string in bytes, followed by the string itself.

Before writing the string, the method calculates the number of bytes needed to represent all characters of the string.

Note: Data written by this method is not immediately transmitted; it is queued until the flush() method is called.

Parâmetros

value:String — The string to write to the socket.


Throws
RangeError — The length is larger than 65535.
 
IOError — An I/O error occurred on the socket, or the socket is not open.

Veja também

writeUTFBytes()método 
public function writeUTFBytes(value:String):void

Writes a UTF-8 string to the socket.

Note: Data written by this method is not immediately transmitted; it is queued until the flush() method is called.

Parâmetros

value:String — The string to write to the socket.


Throws
IOError — An I/O error occurred on the socket, or the socket is not open.

Veja também

Detalhes do evento
close Evento
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.CLOSE

Dispatched when the server closes the socket connection. The close event is dispatched only when the server closes the connection; it is not dispatched when you call the Socket.close() method.

The Event.CLOSE constant defines the value of the type property of a close event object.

This event has the following properties:

PropriedadeValor
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe object whose connection has been closed.
connect Evento  
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.CONNECT

Dispatched when a network connection has been established.

The Event.CONNECT constant defines the value of the type property of a connect event object.

This event has the following properties:

PropriedadeValor
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe Socket or XMLSocket object that has established a network connection.
ioError Evento  
Event Object Type: flash.events.IOErrorEvent
IOErrorEvent.type property = flash.events.IOErrorEvent.IO_ERROR

Dispatched when an input/output error occurs that causes a send or load operation to fail.

Defines the value of the type property of an ioError event object.

This event has the following properties:

PropriedadeValor
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
errorIDA reference number associated with the specific error.
targetThe network object experiencing the input/output error.
textText to be displayed as an error message.
securityError Evento  
Event Object Type: flash.events.SecurityErrorEvent
SecurityErrorEvent.type property = flash.events.SecurityErrorEvent.SECURITY_ERROR

Dispatched if a call to Socket.connect() attempts to connect either to a server outside the caller's security sandbox or to a port lower than 1024.

The SecurityErrorEvent.SECURITY_ERROR constant defines the value of the type property of a securityError event object.

This event has the following properties:

PropriedadeValor
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe network object reporting the security error.
textText to be displayed as an error message.

Veja também

socketData Evento  
Event Object Type: flash.events.ProgressEvent
ProgressEvent.type property = flash.events.ProgressEvent.SOCKET_DATA

Dispatched when a socket has received data. Eventos of type socketData do not use the ProgressEvent.bytesTotal property.

Defines the value of the type property of a socketData event object.

This event has the following properties:

PropriedadeValor
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event.
bytesLoadedThe number of items or bytes loaded at the time the listener processes the event.
bytesTotal0; this property is not used by socketData event objects.
targetThe Socket object reporting progress.
Exemplos How to use examples
SocketExample.as

The following exemplo reads from and writes to a socket and outputs information transmitted during socket events. Highlights of the exemplo follow:
  1. The constructor creates a CustomSocket instance named socket and passes the host name localhost and port 80 as arguments. Since CustomSocket extends Socket, a call to super() calls Socket's constructor with localhost as the host name and 80 as the port number.
  2. The exemplo then calls the configureListeners() method, which adds listeners for Socket events.

Note: To run the exemplo, you need a server running on the same domain where the SWF resides (in the exemplo, localhost) and listening on port 80.


package {
    import flash.display.Sprite;

    public class SocketExample extends Sprite {

        public function SocketExample() {
            var socket:CustomSocket = new CustomSocket("localhost", 80);
        }
    }
}

import flash.errors.*;
import flash.events.*;
import flash.net.Socket;

class CustomSocket extends Socket {
    private var response:String;

    public function CustomSocket(host:String = null, port:uint = 0) {
        super(host, port);
        configureListeners();
    }

    private function configureListeners():void {
        addEventListener(Event.CLOSE, closeHandler);
        addEventListener(Event.CONNECT, connectHandler);
        addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
        addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
        addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);
    }

    private function writeln(str:String):void {
        str += "\n";
        try {
            writeUTFBytes(str);
        }
        catch(e:IOError) {
            trace(e);
        }
    }

    private function sendRequest():void {
        trace("sendRequest");
        response = "";
        writeln("GET /");
        flush();
    }

    private function readResponse():void {
        var str:String = readUTFBytes(bytesAvailable);
        response += str;
    }

    private function closeHandler(event:Event):void {
        trace("closeHandler: " + event);
        trace(response.toString());
    }

    private function connectHandler(event:Event):void {
        trace("connectHandler: " + event);
        sendRequest();
    }

    private function ioErrorHandler(event:IOErrorEvent):void {
        trace("ioErrorHandler: " + event);
    }

    private function securityErrorHandler(event:SecurityErrorEvent):void {
        trace("securityErrorHandler: " + event);
    }

    private function socketDataHandler(event:ProgressEvent):void {
        trace("socketDataHandler: " + event);
        readResponse();
    }
}