Infinity.NameResolver¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/c |
The hostname to be looked up |
||
r/w/c |
I/O handler |
||
r/w/c |
The expected service at the remote endpoint |
||
r/w/c |
The SRV record to look up for the given hostname, e.g. _jabber._tcp |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
This signal is emitted when the hostname has been resolved. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class Infinity.NameResolver(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Infinity.NameResolver
is an opaque data type. You should only access it via the public API functions.- classmethod new(io, hostname, service, srv)¶
- Parameters:
io (
Infinity.Io
) – AInfinity.Io
object used to schedule events in the main thread.hostname (
str
) – The hostname to look up.service (
str
orNone
) – The name of the service to look up, orNone
.
- Returns:
A new
Infinity.NameResolver
. Free withGObject.Object.unref
().- Return type:
Creates a new
Infinity.NameResolver
. UseInfinity.NameResolver.start
() to start resolving the hostname.If service is not
None
, 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 notNone
, 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
None
if the user did not provide an explicit port number. If the resulting port number obtained withInfinity.NameResolver.get_port
() is then different from 0, then use that port number, otherwise the default port number for the service.
- finished()¶
- Returns:
Whether a call to
Infinity.NameResolver.start
() can be made.- Return type:
Returns whether the resolver is currently looking up a hostname, or whether it is ready to start a new lookup with
Infinity.NameResolver.start
().
- get_address(index)¶
- Parameters:
index (
int
) – The index for which to return the address, in case multiple IP addresses correspond to the same hostname.- Returns:
The looked up
Infinity.IpAddress
.- Return type:
Returns the index th address looked up in the last hostname resolution operation.
- get_hostname()¶
-
Returns the currently configured hostname that self will look up.
- get_n_addresses()¶
- Returns:
The number of addresses available.
- Return type:
Returns the number of resolved addresses that belongs to the hostname that was looked up.
- get_port(index)¶
- Parameters:
index (
int
) – The index for which to return the port, in case multiple IP addresses correspond to the same hostname.- Returns:
The looked up
Infinity.IpAddress
.- Return type:
Returns the index th port looked up in the last hostname resolution operation. This can be 0 if the service parameter in
Infinity.NameResolver.start
() has been set toNone
and no SRV record has been found.
- get_service()¶
-
Returns the currently configured service that self will look up.
- get_srv()¶
-
Returns the currently configured SRV record that self will look up.
- lookup_backup()¶
-
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, orTrue
otherwise. If it returnsTrue
, it theInfinity.NameResolver
::resolved
signal will be emitted again, and when it is, more addresses might be available from the resolver object.
- start()¶
- Raises:
- Returns:
- Return type:
Starts the name resolution for the hostname configured with self.
When the hostname lookup has finished, the
Infinity.NameResolver
::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 theInfinity.NameResolver.get_address
() andInfinity.NameResolver.get_port
() functions.
- do_resolved(error) virtual¶
- Parameters:
error (
GLib.Error
) –
Signal Details¶
- Infinity.NameResolver.signals.resolved(name_resolver, error)¶
- Signal Name:
resolved
- Flags:
- Parameters:
name_resolver (
Infinity.NameResolver
) – The object which received the signalerror (
GLib.Error
) – A description of the error that occurred, orNone
.
This signal is emitted when the hostname has been resolved. The function
Infinity.NameResolver.get_address
() andInfinity.NameResolver.get_port
() can be called to obtain the resolved addresses.
Property Details¶
- Infinity.NameResolver.props.hostname¶
-
The hostname to be looked up
- Infinity.NameResolver.props.io¶
- Name:
io
- Type:
- Default Value:
- Flags:
I/O handler
- Infinity.NameResolver.props.service¶
-
The expected service at the remote endpoint