XMLSocket


Object
    |
    +-XMLSocket

public class XMLSocket
extends Object

The XMLSocket class implements client sockets that let the computer running Flash Player 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 lets the server 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 described in the following list:

The following restrictions apply to how and where an XMLSocket object can connect to the server:

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() function, 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 an XMLSocket object.

Availability: ActionScript 1.0; Flash Player 5

Property summary

Properties inherited from class Object

constructor, __proto__, prototype, __resolve


Event summary

Event

Description

onClose = function() {}

Invoked only when an open connection is closed by the server.

onConnect = function(success:Boolean) {}

Invoked by Flash Player when a connection request initiated through XMLSocket.connect() has succeeded or failed.

onData = function(src:String) {}

Invoked when a message has been downloaded from the server, terminated by a zero (0) byte.

onXML = function(src:XML) {}

Invoked by Flash Player when the specified XML object containing an XML document arrives over an open XMLSocket connection.

Constructor summary

Signature

Description

XMLSocket()

Creates a new XMLSocket object.

Method summary

Modifiers

Signature

Description

 

close() : Void

Closes the connection specified by XMLSocket object.

 

connect(url:String, port:Number) : Boolean

Establishes a connection to the specified Internet host using the specified TCP port (must be 1024 or higher), and returns true or false, depending on whether a connection is successfully established.

 

send(data:Object) : Void

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.

Methods inherited from class Object

addProperty, hasOwnProperty, isPropertyEnumerable, isPrototypeOf, registerClass, toString, unwatch, valueOf, watch



Version 8

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00002906.html