Extracted from Pike v7.4 release 341 at 2005-11-21.
pike.ida.liu.se
[Top]
predef::
Stdio
Stdio.File

Method Stdio.File()->async_connect()


Method async_connect

int async_connect(string host, int port, function(int: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 to connect to.

Parameter callback

Function to be called on completion. The first argument will be 1 if a connection was successfully estabished, 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 .

Returns

Returns 0 on failure, and 1 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.

For callback to be called, the backend must be active (ie main() must have returned -1).

The socket will be in non-blocking state if 1 has been returned, and any callbacks will be cleared.

See also

connect() , open_socket() , set_nonblocking()