Top | ![]() |
![]() |
![]() |
![]() |
InfNameResolver * | inf_name_resolver_new () |
const gchar * | inf_name_resolver_get_hostname () |
const gchar * | inf_name_resolver_get_service () |
const gchar * | inf_name_resolver_get_srv () |
gboolean | inf_name_resolver_start () |
gboolean | inf_name_resolver_lookup_backup () |
gboolean | inf_name_resolver_finished () |
guint | inf_name_resolver_get_n_addresses () |
const InfIpAddress * | inf_name_resolver_get_address () |
guint | inf_name_resolver_get_port () |
InfNameResolver provides a portable interface to look up DNS entries. When
a resorver object has been created, the name lookup can be started with
inf_name_resolver_start()
, and once it finishes, the
“resolved” signal is emitted. The
inf_name_resolver_get_address()
and inf_name_resolver_get_port()
functions
can then be used to obtain the result.
There can at most be one hostname lookup at a time. If you need more than one concurrent hostname lookup, use multiple InfNameResolver objects.
InfNameResolver * inf_name_resolver_new (InfIo *io
,const gchar *hostname
,const gchar *service
,const gchar *srv
);
Creates a new InfNameResolver. Use inf_name_resolver_start()
to start
resolving the hostname.
If service
is not NULL
, it should be a decimal port number or a
well-known service name that is translated into a port number, such as
"http". If srv
is not NULL
, the function will first attempt
a SRV lookup, and fall back to a regular A/AAAA lookup in case no SRV
record exists. Otherwise the SRV result is taken. If service
is
provided, it always overwrites the port number obtained from the hostname
lookup.
The recommended procedure is to call this function with service
equal to
the port number entered by the user, or NULL
if the user did not provide
an explicit port number. If the resulting port number obtained with
inf_name_resolver_get_port()
is then different from 0, then use that
port number, otherwise the default port number for the service.
[constructor]
io |
A InfIo object used to schedule events in the main thread. |
|
hostname |
The hostname to look up. |
|
service |
The name of the service to look up, or |
[allow-none] |
srv |
The SRV record to look up, or |
[allow-none] |
const gchar *
inf_name_resolver_get_hostname (InfNameResolver *resolver
);
Returns the currently configured hostname that resolver
will look up.
const gchar *
inf_name_resolver_get_service (InfNameResolver *resolver
);
Returns the currently configured service that resolver
will look up.
const gchar *
inf_name_resolver_get_srv (InfNameResolver *resolver
);
Returns the currently configured SRV record that resolver
will look up.
gboolean inf_name_resolver_start (InfNameResolver *resolver
,GError **error
);
Starts the name resolution for the hostname configured with resolver
.
When the hostname lookup has finished, the “resolved”
signal is emitted. The function can only be called again once this signal
has been emitted. When this function is called, the previously looked up
result can no longer be obtained with the inf_name_resolver_get_address()
and inf_name_resolver_get_port()
functions.
gboolean inf_name_resolver_lookup_backup (InfNameResolver *resolver
,GError **error
);
Tries to look up backup addresses for the configured hostname. This should
be used if connecting to none of the initially reported addresses works.
The function returns FALSE
if there are no backup addresses available, or
TRUE
otherwise. If it returns TRUE
, it the “resolved”
signal will be emitted again, and when it is, more addresses might be
available from the resolver object.
gboolean
inf_name_resolver_finished (InfNameResolver *resolver
);
Returns whether the resolver is currently looking up a hostname, or whether
it is ready to start a new lookup with inf_name_resolver_start()
.
guint
inf_name_resolver_get_n_addresses (InfNameResolver *resolver
);
Returns the number of resolved addresses that belongs to the hostname that was looked up.
const InfIpAddress * inf_name_resolver_get_address (InfNameResolver *resolver
,guint index
);
Returns the index
th address looked up in the last hostname
resolution operation.
guint inf_name_resolver_get_port (InfNameResolver *resolver
,guint index
);
Returns the index
th port looked up in the last hostname
resolution operation. This can be 0 if the service
parameter in
inf_name_resolver_start()
has been set to NULL
and no SRV record has
been found.
struct InfNameResolver;
InfNameResolver is an opaque data type. You should only access it via the public API functions.
struct InfNameResolverClass { /* Signals */ void (*resolved)(InfNameResolver* connection, const GError* error); };
This structure contains the default signal handlers of InfNameResolver.
“hostname”
property “hostname” char *
The hostname to be looked up.
Owner: InfNameResolver
Flags: Read / Write / Construct
Default value: NULL
“service”
property “service” char *
The expected service at the remote endpoint.
Owner: InfNameResolver
Flags: Read / Write / Construct
Default value: NULL
“resolved”
signalvoid user_function (InfNameResolver *resolver, GError *error, gpointer user_data)
This signal is emitted when the hostname has been resolved. The function
inf_name_resolver_get_address()
and inf_name_resolver_get_port()
can be
called to obtain the resolved addresses.
resolver |
The InfNameResolver that has resolved a hostname. |
|
error |
A description of the error that occurred, or |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last