X-Z > XMLSocket.connect
XMLSocket.connectSyntax
myXMLSocket
.connect(
host, port
);
Arguments
host
A fully qualified DNS domain name, or a IP address in the form aaa.bbb.ccc.ddd. You can also specify null
to connect to the host server on which the movie resides.
port
The TCP port number on the host used to establish a connection. The port number must be 1024 or higher.
Description
Method; 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. If you don't know the port number of your Internet host machine, contact your network administrator. If the Flash Netscape plug-in or ActiveX control is being used, the host specified in the argument must have the same subdomain as the host from where the movie was downloaded.
If you specify null
for the host
argument, the host contacted will be the host where the movie calling XMLSocket.connect
resides. For example, if the movie was downloaded from http://www.yoursite.com, specifying null
for the host argument is the same as entering the IP address for www.yoursite.com.
If XMLSocket.connect
returns a value of true
, the initial stage of the connection process is successful; later, the XMLSocket.onConnect
method is invoked to determine whether the final connection succeeded or failed. If XMLSocket.connect
returns false
, a connection could not be established.
Player
Flash 5 or later.
Example
The following example uses XMLSocket.connect
to connect to the host where the movie resides, and uses trace
to display the return value indicating the success or failure of the connection:
function myOnConnect(success) { if (success) { trace ("Connection succeeded!") } else { trace ("Connection failed!") } } socket = new XMLSocket() socket.onConnect = myOnConnect if (!socket.connect(null, 2000)) { trace ("Connection failed!") }
See also
function XMLSocket.onConnect