
ADOBE FLASH MEDIA INTERACTIVE SERVER
Server-Side ActionScript Language Reference
146
XMLSocket class
The XMLSocket class implements client sockets that let Flash Media Interactive Server communicate with a server
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 polls the server frequently and
downloads new messages by using an HTTP request. In contrast, an XMLSocket chat solution maintains an open
connection to the server, which lets the server send incoming messages immediately, without a request from the
client.
Note: You can also use the XMLSocket class to create an XMLStreams object. See XMLSocket constructor and
XMLStreams class.
To use the XMLSocket class, the server computer must run a daemon that understands the protocol used by this
class. The protocol has the following characteristics:
• 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 (0) byte.
• An unlimited number of XML messages can be sent and received over a single XMLSocket connection.
The following restriction applies 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 less than 1024 are often used by system
services such as FTP, Telnet, and HTTP, which prohibits XMLSocket objects from these ports for security reasons.
The port number restriction limits the possibility that these resources can be inappropriately accessed and abused.
To use the methods of the XMLSocket class, you must first use the constructor,
new XMLSocket(), to create an
XMLSocket object.
Availability
Flash Media Server 2
Property summary
Method summary
Property Description
XMLSocket.maxUnprocessedChars The number of characters the connection can receive from the XML server without receiving
an end tag or the XMLSocket connection closes.
Method Description
XMLSocket.close() Closes the connection specified by the XMLSocket object.
XMLSocket.connect() Establishes a connection to the specified Internet host by using the specified TCP port (must
be 1024 or higher), and returns true or false, depending on whether a connection is
successfully established.
XMLSocket.send() Converts the XML object or data specified in the object parameter to a string and transmits
it to the server, followed by a zero (0) byte.
Commenti su questo manuale