774
Chapter 12: ActionScript Dictionary
XMLSocket class
Availability
Flash Player 5.
Description
The XMLSocket class implements client sockets that allow the computer running Flash Player to
communicate with a server computer identified by an IP address or domain name. The
XMLSocket class is useful for client-server applications that require low latency, such as real-time
chat systems. A traditional HTTP-based chat solution frequently polls the server and downloads
new messages using an HTTP request. In contrast, an XMLSocket chat solution maintains an
open connection to the server, which allows the server to immediately send incoming messages
without a request from the client.
To use the XMLSocket class, the server computer must run a daemon that understands the
protocol used by the XMLSocket class. The protocol is as follows:
•
XML messages are sent over a full-duplex TCP/IP stream socket connection.
•
Each XML message is a complete XML document, terminated by a zero byte.
•
An unlimited number of XML messages can be sent and received over a single
XMLSocket connection.
The following restrictions apply to how and where an XMLSocket object can connect to
the server:
•
The
XMLSocket.connect()
method can connect only to TCP port numbers greater than or
equal to 1024. One consequence of this restriction is that the server daemons that
communicate with the XMLSocket object must also be assigned to port numbers greater than
or equal to 1024. Port numbers below 1024 are often used by system services such as FTP,
Telnet, and HTTP, thus XMLSocket objects are barred from these ports for security reasons.
The port number restriction limits the possibility that these resources will be inappropriately
accessed and abused.
•
The
XMLSocket.connect()
method can connect only to computers in the same domain
where the SWF file resides. This restriction does not apply to SWF files running off a local
disk. (This restriction is identical to the security rules for
loadVariables()
,
XML.sendAndLoad()
, and
XML.load()
.) To connect to a server daemon running in a domain
other than then one where the SWF resides, you can create a security policy file on the server
that allows access from specific domains. For more information on creating policy files for
XMLSocket connections, see
“About allowing cross-domain data loading” on page 190
.
Setting up a server to communicate with the XMLSocket object can be challenging. If your
application does not require real-time interactivity, use the
loadVariables()
action, or Flash
HTTP-based XML server connectivity (
XML.load()
,
XML.sendAndLoad()
,
XML.send()
),
instead of the XMLSocket class.
To use the methods of the XMLSocket class, you must first use the constructor,
new XMLSocket
,
to create a new XMLSocket object.
Summary of Contents for FLASH MX 2004 - ACTIONSCRIPT
Page 1: ...ActionScript Reference Guide...
Page 8: ...8 Contents...
Page 12: ......
Page 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Page 54: ...54 Chapter 2 ActionScript Basics...
Page 80: ...80 Chapter 3 Writing and Debugging Scripts...
Page 82: ......
Page 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Page 112: ......
Page 120: ...120 Chapter 6 Using the Built In Classes...
Page 176: ......
Page 192: ...192 Chapter 10 Working with External Data...
Page 202: ...202 Chapter 11 Working with External Media...
Page 204: ......
Page 782: ...782 Chapter 12 ActionScript Dictionary...
Page 793: ...Other keys 793 221 222 Key Key code...
Page 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Page 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Page 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Page 816: ...816 Index...