Method Stdio.File()->async_connect()
- Method
async_connect
int
async_connect(string(7bit)
host
,int
|string(7bit)
port
,function
(int
,__unknown__
... :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
1
if a connection was successfully established, and0
(zero) on failure. The rest of the arguments to callback are passed verbatim from args.- Parameter
args
Extra arguments to pass to callback.
- Returns
Returns
0
on failure to open a socket, and1
if callback will 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 callback to 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
- Method
async_connect
variant
Concurrent.Future
async_connect(string(7bit)
host
,int
|string(7bit)
port
)- Description
Opens a TCP connection asynchronously using a Concurrent Future object.
- Parameter
host
Hostname or IP to connect to.
- Parameter
port
Port number or service name to connect to.
- Returns
Returns a Concurrent.Future that resolves into the connection object at success.