03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

XMLSocket<br />

Object<br />

|<br />

+-XMLSocket<br />

public class XMLSocket<br />

extends Object<br />

The XMLSocket class implements client sockets that let the device running the Flash Lite<br />

player communicate with a server computer that an IP address or domain name identifies.<br />

The XMLSocket class is useful for client-server applications that require low latency, such as<br />

real-time chat systems. A traditional HTTP-based chat system frequently polls the server <strong>and</strong><br />

downloads new messages by using an HTTP request. In contrast, an XMLSocket chat<br />

solution maintains an open connection to the server, which lets the server immediately send<br />

incoming messages without a request from the client.<br />

To use the XMLSocket class, the server computer must run a daemon process that<br />

underst<strong>and</strong>s the protocol that the XMLSocket class uses. The following list describes the<br />

protocol:<br />

■ XML messages are sent over a full-duplex TCP/IP stream socket connection.<br />

■ Each XML message is a complete XML document, terminated by a zero (0) byte.<br />

■ An unlimited number of XML messages can be sent <strong>and</strong> received over a single<br />

XMLSocket connection.<br />

The following restrictions apply to how <strong>and</strong> where an XMLSocket object can connect to the<br />

server:<br />

■ To connect an XMLSocket to a port lower than 1024, you must first load a policy file<br />

with the System.security.loadPolicyFile() method, even when your application<br />

connects to its own exact domain.<br />

■ The XMLSocket.connect() method can connect only to computers in the same domain<br />

where the SWF file resides. This restriction does not apply to SWF files running on a local<br />

disk. (This restriction is identical to the security rules for the loadVariables() function,<br />

<strong>and</strong> the XML.sendAndLoad() <strong>and</strong> XML.load() methods.) To connect to a server daemon<br />

running in a domain other than the one where the SWF file resides, you can create a<br />

security policy file on the server that allows access from specific domains.<br />

Setting up a server to communicate with the XMLSocket object can be challenging. If your<br />

application does not require real-time interactivity, use the loadVariables() function, or<br />

Flash HTTP-based XML server connectivity methods (XML.load(), XML.sendAndLoad(),<br />

XML.send()), instead of the XMLSocket class.<br />

714 ActionScript classes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!