![]() |
![]() |
![]() |
GNetwork Library Manual | ![]() |
---|---|---|---|---|
GNetworkDnsEntry; void (*GNetworkDnsCallbackFunc) (const GSList *entries, const GError *error, gpointer user_data); typedef GNetworkDnsHandle; #define GNETWORK_DNS_HANDLE_INVALID GNetworkDnsHandle gnetwork_dns_get (const gchar *address, GNetworkDnsCallbackFunc callback, gpointer data, GDestroyNotify notify); GNetworkDnsHandle gnetwork_dns_get_from_ip (const GNetworkIpAddress *ip_address, GNetworkDnsCallbackFunc callback, gpointer data, GDestroyNotify notify); void gnetwork_dns_cancel (GNetworkDnsHandle handle); GNetworkDnsEntry* gnetwork_dns_entry_new (const gchar *hostname, const GNetworkIpAddress *ip_address); const gchar* gnetwork_dns_entry_get_hostname (const GNetworkDnsEntry *entry); void gnetwork_dns_entry_set_hostname (GNetworkDnsEntry *entry, const gchar *hostname); const GNetworkIpAddress* gnetwork_dns_entry_get_ip_address (const GNetworkDnsEntry *entry); void gnetwork_dns_entry_set_ip_address (GNetworkDnsEntry *entry, const GNetworkIpAddress *ip_address); void gnetwork_dns_entry_free (GNetworkDnsEntry *entry); GNetworkDnsEntry* gnetwork_dns_entry_dup (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.
typedef struct _GNetworkDnsEntry GNetworkDnsEntry;
A structure used to hold a DNS lookup return.
void (*GNetworkDnsCallbackFunc) (const GSList *entries, const GError *error, gpointer user_data);
A user function which is called when an DNS lookup is completed.
entries : |
the result of the lookup. |
error : |
an error, if one occurred. |
user_data : |
the user-supplied data. |
typedef GNetworkDnsLookup *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_HANDLE_INVALID NULL
A defined constant for an invalid DNS lookup handle.
GNetworkDnsHandle gnetwork_dns_get (const gchar *address, GNetworkDnsCallbackFunc callback, gpointer data, GDestroyNotify notify);
This function performs an asynchronous DNS lookup (or reverse lookup) on the
hostname or IP address in address
. After callback
has been called, notify
will be called with data
as it's argument. If there an error occurred trying
to create the DNS lookup thread, error
will be set, and
GNETWORK_DNS_HANDLE_INVALID will be returned.
Note: callback
may be called before this function returns if there was a
threading error.
address : |
the hostname or IP address to find. |
callback : |
the callback to be called when the lookup has completed. |
data : |
the user data to pass to callback .
|
notify : |
a function capable of freeing user_data , or NULL .
|
Returns : | a GNetworkDnsHandle used to cancel the lookup. |
Since 1.0
GNetworkDnsHandle gnetwork_dns_get_from_ip (const GNetworkIpAddress *ip_address, GNetworkDnsCallbackFunc callback, gpointer data, GDestroyNotify notify);
This function performs an asynchronous DNS reverse lookup on the IP address
in ip_address
. After callback
has been called, notify
will be called with
data
as it's argument. If an error occurred the callback will be called with
the error argument set.
Note: callback
may be called before this function returns if there was a
threading error.
ip_address : |
the IP address to find. |
callback : |
the callback to be called when the lookup has completed. |
data : |
the user data to pass to callback .
|
notify : |
a function capable of freeing user_data , 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
callback associated with handle
from being called. (The lookup will still
finish.)
handle : |
a GNetworkDnsHandle for a running lookup. |
Since 1.0
GNetworkDnsEntry* gnetwork_dns_entry_new (const gchar *hostname, const GNetworkIpAddress *ip_address);
Creates a new host-to-IP structure with the appropriate values from hostname
and ip_address
. The returned value should be freed with
gnetwork_dns_entry_free()
when no longer needed.
hostname : |
the hostname to set, or NULL .
|
ip_address : |
the IP address to set, or NULL .
|
Returns : | GNetworkDnsEntry structure. |
Since 1.0
const gchar* gnetwork_dns_entry_get_hostname (const GNetworkDnsEntry *entry);
Retrieves the hostname pointer from entry
. The returned value should not be
modified or freed.
entry : |
the DNS entry to examine. |
Returns : | the hostname of entry .
|
Since 1.0
void gnetwork_dns_entry_set_hostname (GNetworkDnsEntry *entry, const gchar *hostname);
Modifies entry
to use the contents of hostname
for it's hostname.
entry : |
the DNS entry to modify. |
hostname : |
the new hostname, or NULL .
|
Since 1.0
const GNetworkIpAddress* gnetwork_dns_entry_get_ip_address (const GNetworkDnsEntry *entry);
Retrieves a pointer to the IP address of entry
. The returned data should not
be modified or freed.
entry : |
the DNS entry to examine. |
Returns : | the GNetworkIpAddress of entry .
|
Since 1.0
void gnetwork_dns_entry_set_ip_address (GNetworkDnsEntry *entry, const GNetworkIpAddress *ip_address);
Modifies entry
to use the contents of ip_address
for it's IP address.
entry : |
the DNS entry to modify. |
ip_address : |
the new hostname, or NULL .
|
Since 1.0
void gnetwork_dns_entry_free (GNetworkDnsEntry *entry);
Frees the data used by entry
.
entry : |
the DNS entry to destroy. |
Since 1.0
GNetworkDnsEntry* gnetwork_dns_entry_dup (const GNetworkDnsEntry *src);
Creates a copy of the data in src
. The returned data should be freed with
gnetwork_dns_entry_free()
when no longer needed.
src : |
the DNS entry to duplicate. |
Returns : | a copy of src .
|
Since 1.0