![]() | ![]() | ![]() | GNetwork Library Manual | ![]() |
---|
DNS Lookups — Performing DNS queries.
struct GNetworkDnsEntry; void (*GNetworkDnsCallbackFunc) (const GNetworkDnsEntry *entry, gpointer user_data); typedef GNetworkDnsHandle; #define GNETWORK_DNS_INVALID_HANDLE GNetworkDnsHandle gnetwork_dns_get (const gchar *address, GNetworkDnsCallbackFunc callback, gpointer user_data, GDestroyNotify destroy_data, GError **error); void gnetwork_dns_cancel (GNetworkDnsHandle handle); GNetworkDnsEntry* gnetwork_dns_entry_new (void); void gnetwork_dns_entry_free (GNetworkDnsEntry *entry); GNetworkDnsEntry* gnetwork_dns_entry_copy (const GNetworkDnsEntry *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 GNetworkTcpConnection and GNetworkTcpServer perform these lookups automatically, as directed or needed.
struct GNetworkDnsEntry { GNetworkDnsError error; gchar *hostname; GSList *aliases; GSList *ip_addresses; };
A structure used to hold a DNS lookup return.
GNetworkDnsError error | the GNetworkDnsError code, if any. |
gchar *hostname | the cannonical name of the host. |
GSList *aliases | a list of alternate names of the host. |
GSList *ip_addresses | a list of IP addresses corresponding to hostname. |
void (*GNetworkDnsCallbackFunc) (const GNetworkDnsEntry *entry, gpointer user_data);
A user function which is called when an DNS lookup is completed.
entry : | the result of the lookup. |
user_data : | the user-supplied data. |
typedef glong GNetworkDnsHandle;
A handle returned by gnetwork_dns_get(). The handle can be used to cancel DNS lookups. See gnetwork_dns_get() and gnetwork_dns_cancel().
#define GNETWORK_DNS_INVALID_HANDLE -1
An invalid return from gnetwork_dns_get().
GNetworkDnsHandle gnetwork_dns_get (const gchar *address, GNetworkDnsCallbackFunc callback, gpointer user_data, GDestroyNotify destroy_data, GError **error);
This function performs an asynchronous DNS lookup (or reverse lookup) on the hostname or IP address in address. After callback has been called, user_data will be destroyed using destroy_data. If there an error occurred trying to create the DNS lookup thread, error will be set, and GNETWORK_DNS_INVALID_HANDLE will be returned.
Note: callback may be called before this function returns if the DNS record for address is already in the DNS cache.
address : | the hostname or IP address to find. |
callback : | the callback to be called when the lookup has completed. |
user_data : | the user data to pass to callback. |
destroy_data : | a function capable of freeing user_data, or NULL. |
error : | a location to store threading errors, or NULL. |
Returns : | a GNetworkDnsHandle used to cancel the lookup. |
Since 1.0
void gnetwork_dns_cancel (GNetworkDnsHandle handle);
This function prevents an asynchronous DNS lookup (or reverse lookup) from completing.
Note: This function will not actually stop a DNS lookup, only prevent the callbacks associated with handle from being called. (The lookup will still finish and the results will still be cached.)
handle : | a GNetworkDnsHandle for a running lookup. |
Since 1.0
GNetworkDnsEntry* gnetwork_dns_entry_new (void);
Allocates a new GNetworkDnsEntry structure. The returned data should be freed with gnetwork_dns_entry_free().
Returns : | an empty DNS entry reply structure. |
Since 1.0
void gnetwork_dns_entry_free (GNetworkDnsEntry *entry);
This function frees a GNetworkDnsEntry.
entry : | the GNetworkDnsEntry to free. |
Since 1.0
GNetworkDnsEntry* gnetwork_dns_entry_copy (const GNetworkDnsEntry *src);
Copies an existing a GNetworkDnsEntry. The returned data should be freed with gnetwork_dns_entry_free() when no longer needed.
src : | the entry to copy. |
Returns : | a copy of src. |
Since 1.0
<< Thread Support | Proxy Support >> |