Name
XMLSocket.connect( ) Method — open a connection to a server application
Availability
Flash 5
Synopsis
socket.connect(host, port)
Arguments
- host
A string specifying a hostname such as
"www.myserver.com"
or a standard IP address (four, dot-separated, 8-bit, decimal integers such as 111.222.3.123). Ifnull
or an empty string is specified, it defaults to the server address from which the movie was served.
- port
An integer specifying a TCP port number greater than or equal to 1024.
Returns
A Boolean indicating the initial success (true
) or
failure (false
) of the connection attempt.
Description
The connect( )
method attempts to establish a
connection from Flash to a server application running on
host
at port
.
If connect( )
returns true
,
the initial phase of the connection completed successfully and the
socket
’s onConnect(
)
handler will be invoked at a later time. From the
onConnect( )
handler, we can evaluate whether
the connection was fully established. Note that connection attempts
can take varying amounts of time, particularly when a connection
attempt fails. You should indicate to the user that a connection
attempt is in progress when invoking connect( )
.
If connect( )
returns false
,
the initial connection phase did not complete successfully. In such a
case, socket
’s onConnect(
)
handler will not be invoked.
It is important to check both the return value of the
connect( )
method and, if connect(
)
returns true
, the value of the
success
parameter of the
onConnect( )
handler.
Usage
For security ...
Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.