- Method async_connect
int async_connect(string host, int|string port, function(int, mixed ... :void) callback, mixed ... args)
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, and
0(zero) on failure. The rest of the arguments to callback are passed verbatim from args.
- Parameter args
Extra arguments to pass to callback.
0on failure, and
1if callback will be used.
The socket may be opened with open_socket() ahead of the call to this function, but it is not required.
This object is put in callback mode by this function. For callback to be called, the backend must be active. See e.g. set_read_callback for more details about backends and callback mode.
The socket will be in nonblocking state if the connection is successful, and any callbacks will be cleared.
- See also