getdns Functions
PHP Manual


(PECL getdns >= 0.10.0)

php_getdns_hostnameAsynchronously retrieve host names given an IP address.


int php_getdns_hostname ( int $context , int $address , int $extensions , array $userArg , mixed &$transID )

This function provides an entry point into the getdns API library to asynchronously retrieve host names given an IPv4 or IPv6 address. See php_getdns_hostname_sync() for a description of the response data structure.

Note that this function enqueues an event that must be processed to produce queries and return results. Calling php_context_run() after calling this function will ensure that all queued events are processed.



The previously created DNS context that is to be used with this request.


A reference to a dictionary structure containing two names: address_type (whose value is bindata and is either "IPv4" or "IPv6") and address_data (whose value is a binary character string (bindata) representing the address to be resolved).


The extensions dictionary for this request; NULL or 0 (zero) if no extensions.


An indexed array that contains information used to control callback processing. The first element of the array must contain a character string representing the name of the PHP client function that will receive and process the result of the DNS query. Additional array elements are optional and may be included to be passed to the callback function. The callback function will receive the complete array for local processing with all elements included as specified.

The callback function should be declared as follows:

        function_name($dict, $callbackType, $userArg, $transID)
        // $dict: An int representing the dictionary containing the response.
        // $callbackType: The getdns callback type.
        // $userArg: The original user arguments provided by the caller.
        // $transID: A 16-character string in hex format that contains the identifier of the transaction being processed.


A 16-character string value in hexadecimal format representing an unsigned 64-bit integer that is filled in by the function to identify the callback being made. This value is passed by reference and any existing value will be overwritten; an empty string ("") is acceptable on input. It can also be NULL, in which case it is ignored and no value is assigned. The php_getdns_cancel_callback() function uses the transID to determine which callback is to be cancelled.

Return Values

This function returns an integer response code. GETDNS_RETURN_GOOD indicates successful completion.

getdns Functions
PHP Manual