![]() | ![]() | ![]() | GTcpSocket Library Manual | ![]() |
---|
DNS Lookups — Performing DNS queries.
struct GTcpDNSEntry; void (*GTcpDNSCallbackFunc) (const GTcpDNSEntry *entry, gpointer user_data); typedef GTcpDNSHandle; #define GTCP_DNS_INVALID_HANDLE #define gtcp_dns_get (address,callback,user_data) GTcpDNSHandle gtcp_dns_get_full (const gchar *address, GTcpDNSCallbackFunc callback, gpointer user_data, GDestroyNotify destroy_data); void gtcp_dns_cancel (GTcpDNSHandle handle); void gtcp_dns_entry_free (GTcpDNSEntry *entry); GTcpDNSEntry* gtcp_dns_entry_copy (const GTcpDNSEntry *src);
These methods provide a means to asynchronously perform DNS lookups on hostnames or reverse DNS lookups on addresses. This typically does not need to be done, as GTcpConnection and GTcpServer perform these lookups automatically, as directed or needed.
struct GTcpDNSEntry { GTcpLookupStatus status; gchar *hostname; GSList *aliases; GSList *ip_addresses; };
An enhanced version of the standard hostent struct.
GTcpLookupStatus status | the status code of the lookup (see GTcpLookupStatus and gtcp_error_get_lookup_status_message()). |
gchar *hostname | the cannonical hostname (may be NULL if there is no DNS record for this hostname or address). |
GSList *aliases | a list of hostname aliases for this DNS record (if any). |
GSList *ip_addresses | a list of IP addresses for this DNS record (if any). |
Since 1.0
void (*GTcpDNSCallbackFunc) (const GTcpDNSEntry *entry, gpointer user_data);
The callback function invoked when a DNS lookup has returned. Note that entry is not gauranteed to be static for any longer than the duration of the callback function. If you wish to save the data in entry, you should copy it with gtcp_dns_entry_copy().
entry : | the DNS lookup return. |
user_data : | the specified user data. |
Since 1.0
typedef glong GTcpDNSHandle;
A GTcpDNSHandle is used to cancel a callback for a particular lookup attempt.
#define GTCP_DNS_INVALID_HANDLE -1
If an internal or programming error is encountered in gtcp_dns_get(), this value will be returned.
#define gtcp_dns_get(address,callback,user_data)
Performs a DNS lookup of address.
address : | the hostname or IP address to lookup. |
callback : | the callback function which will be called when the DNS lookup has finished. |
user_data : | the user data to pass the callback function. |
Returns : | a new GTcpDNSHandle |
Since 1.0
GTcpDNSHandle gtcp_dns_get_full (const gchar *address, GTcpDNSCallbackFunc callback, gpointer user_data, GDestroyNotify destroy_data);
This function performs an asynchronous DNS lookup (or reverse lookup) on the hostname or IP address in address. Note that callback may be called before this function returns if the DNS record for address is in the cache. After callback has been called, user_data will be destroyed using destroy_data.
address : | the local address to get the GTcpDNSEntry for. |
callback : | the callback to be called when the lookup has completed. |
user_data : | the user data to pass to the callback. |
destroy_data : | a function capable of freeing user_data, or NULL. |
Returns : | a GTcpDNSHandle used to cancel the callback. |
Since 1.0
void gtcp_dns_cancel (GTcpDNSHandle handle);
This function prevents an asynchronous DNS lookup (or reverse lookup) from calling it's callback unless it has already been called. NOTE: This function will not actually stop a DNS lookup, only prevent the callback associated with handle from being called. (The lookup will still finish and the results will still be cached.)
handle : | a GTcpDNSHandle for a running lookup. |
Since 1.0
void gtcp_dns_entry_free (GTcpDNSEntry *entry);
This function frees a GTcpDNSEntry.
entry : | the GTcpDNSEntry to free. |
Since 1.0
GTcpDNSEntry* gtcp_dns_entry_copy (const GTcpDNSEntry *src);
Copies an existing a GTcpDNSEntry. The returned data should be freed with gtcp_dns_entry_free() when no longer needed.
src : | the entry to copy. |
Returns : | a copy of src. |
Since 1.0
<< GTcpServer | Proxy Support >> |