Method Stdio.File()->async_connect()
- Method
async_connect
intasync_connect(stringhost,int|stringport,function(int,mixed... :void)callback,mixed...args)- Description
Open a TCP/IP connection asynchronously.
This function is similar to connect(), but works asynchronously.
- Parameter
host Hostname or IP to connect to.
- Parameter
port Port number or service name to connect to.
- Parameter
callback Function to be called on completion. The first argument will be
1if a connection was successfully established, and0(zero) on failure. The rest of the arguments tocallbackare passed verbatim fromargs.- Parameter
args Extra arguments to pass to
callback.- Returns
Returns
0on failure, and1ifcallbackwill be used.- Note
The socket may be opened with open_socket() ahead of the call to this function, but it is not required.
- Note
This object is put in callback mode by this function. For
callbackto be called, the backend must be active. See e.g. set_read_callback for more details about backends and callback mode.- Note
The socket will be in nonblocking state if the connection is successful, and any callbacks will be cleared.
- See also