13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

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.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Sockets<br />

Binary cli<strong>en</strong>t sockets<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

A binary socket connection is similar to an XML socket except that the cli<strong>en</strong>t and server are not limited to exchanging<br />

XML messages. Instead, the connection can transfer data as binary information. Thus, you can connect to a wider<br />

range of services, including mail servers (POP3, SMTP, and IMAP), and news servers (NNTP).<br />

Socket class<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

The Socket class <strong>en</strong>ables you to make socket connections and to read and write raw binary data. The Socket class is<br />

useful for interoperating with servers that use binary protocols. By using binary socket connections, you can write code<br />

that interacts with several differ<strong>en</strong>t Internet protocols, such as POP3, SMTP, IMAP, and NNTP. This interaction, in<br />

turn, <strong>en</strong>ables your applications to connect to mail and news servers.<br />

Flash Player can interface with a server by using the binary protocol of that server directly. Some servers use the big<strong>en</strong>dian<br />

byte order, and some use the little-<strong>en</strong>dian byte order. Most servers on the Internet use the big-<strong>en</strong>dian byte order<br />

because “network byte order” is big-<strong>en</strong>dian. The little-<strong>en</strong>dian byte order is popular because the Intel® x86 architecture<br />

uses it. You should use the <strong>en</strong>dian byte order that matches the byte order of the server that is s<strong>en</strong>ding or receiving data.<br />

All operations that are performed by the IDataInput and IDataOutput interfaces, and the classes that implem<strong>en</strong>t those<br />

interfaces (ByteArray, Socket, and URLStream), are <strong>en</strong>coded by default in big-<strong>en</strong>dian format; that is, with the most<br />

significant byte first. This default byte order was chos<strong>en</strong> to match Java and the official network byte order. To change<br />

whether big-<strong>en</strong>dian or little-<strong>en</strong>dian byte order is used, you can set the <strong>en</strong>dian property to Endian.BIG_ENDIAN or<br />

Endian.LITTLE_ENDIAN.<br />

The Socket class inherits all the methods defined by the IDataInput and IDataOutput interfaces (located in the<br />

flash.utils package). Those methods must be used to write to and read from the Socket.<br />

For more information, see:<br />

Socket<br />

IDataInput<br />

IDataOutput<br />

socketData ev<strong>en</strong>t<br />

Secure cli<strong>en</strong>t sockets (AIR)<br />

Adobe AIR 2 and later<br />

You can use the SecureSocket class to connect to socket servers that use Secure Sockets Layer version 4 (SSLv4) or<br />

Transport Layer Security version 1 (TLSv1). A secure socket provides three b<strong>en</strong>efits: server auth<strong>en</strong>tication, data<br />

integrity, and message confid<strong>en</strong>tiality. The runtime auth<strong>en</strong>ticates a server using the server certificate and its<br />

relationship to the root or intermediate certificate authority certificates in the user’s trust store. The runtime relies on<br />

the cryptography algorithms used by the SSL and TLS protocol implem<strong>en</strong>tations to provide data integrity and message<br />

confid<strong>en</strong>tiality.<br />

Wh<strong>en</strong> you connect to a server using the SecureSocket object, the runtime validates the server certificate using the<br />

certificate trust store. On Windows and Mac, the operating system provides the trust store. On Linux, the runtime<br />

provides its own trust store.<br />

Last updated 6/6/2012<br />

797

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

Saved successfully!

Ooh no, something went wrong!