Infinity.NameResolver¶
| Subclasses: | None | 
|---|
Methods¶
| Inherited: | GObject.Object (37) | 
|---|---|
| Structs: | GObject.ObjectClass (5) | 
| class | new(io, hostname, service, srv) | 
| finished() | |
| get_address(index) | |
| get_hostname() | |
| get_n_addresses() | |
| get_port(index) | |
| get_service() | |
| get_srv() | |
| lookup_backup() | |
| start() | 
Properties¶
| Name | Type | Flags | Short Description | 
|---|---|---|---|
| hostname | str | r/w/c | The hostname to be looked up | 
| io | Infinity.Io | r/w/c | I/O handler | 
| service | str | r/w/c | The expected service at the remote endpoint | 
| srv | str | r/w/c | The SRV record to look up for the given hostname, e.g. _jabber._tcp | 
Signals¶
| Inherited: | GObject.Object (1) | 
|---|
| Name | Short Description | 
|---|---|
| resolved | This signal is emitted when the hostname has been resolved. | 
Class Details¶
- 
class Infinity.NameResolver(**kwargs)¶
- Bases: - GObject.Object- Abstract: - No - Structure: - Infinity.NameResolverClass- Infinity.NameResolveris 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.Ioobject used to schedule events in the main thread.
- hostname (str) – The hostname to look up.
- service (strorNone) – The name of the service to look up, orNone.
- srv (strorNone) – The SRV record to look up, orNone.
 - Returns: - A new - Infinity.NameResolver. Free with- GObject.Object.unref().- Return type: - Creates a new - Infinity.NameResolver. Use- Infinity.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 not- None, 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 - Noneif the user did not provide an explicit port number. If the resulting port number obtained with- Infinity.NameResolver.get_port() is then different from 0, then use that port number, otherwise the default port number for the service.
- io (
 - 
finished()¶
- Returns: - Whether a call to - Infinity.NameResolver.start() can be made.- Return type: - bool- 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: - Infinity.IpAddress- Returns the index th address looked up in the last hostname resolution operation. 
 - 
get_hostname()¶
- Returns: - The currently configured hostname. - Return type: - stror- None- Returns the currently configured hostname that self will look up. 
 - 
get_n_addresses()¶
- Returns: - The number of addresses available. - Return type: - int- 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: - int- 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 to- Noneand no SRV record has been found.
 - 
get_service()¶
- Returns: - The currently configured service. - Return type: - stror- None- Returns the currently configured service that self will look up. 
 - 
get_srv()¶
- Returns: - The currently configured SRV record. - Return type: - stror- None- Returns the currently configured SRV record that self will look up. 
 - 
lookup_backup()¶
- Raises: - GLib.Error- Returns: - Trueif looking up backup addresses is attempted, or- Falseotherwise.- Return type: - bool- 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 - Falseif there are no backup addresses available, or- Trueotherwise. If it returns- True, it the- Infinity.NameResolver- ::resolvedsignal will be emitted again, and when it is, more addresses might be available from the resolver object.
 - 
start()¶
- Raises: - GLib.Error- Returns: - Trueon success or- Falseif a (synchronous) error occurred.- Return type: - bool- Starts the name resolution for the hostname configured with self. - When the hostname lookup has finished, the - Infinity.NameResolver- ::resolvedsignal 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- Infinity.NameResolver.get_address() and- Infinity.NameResolver.get_port() functions.
 - 
do_resolved(error) virtual¶
- Parameters: - error ( - GLib.Error) –
 
- 
classmethod 
Signal Details¶
- 
Infinity.NameResolver.signals.resolved(name_resolver, error)¶
- Signal Name: - resolved- Flags: - Parameters: - name_resolver (Infinity.NameResolver) – The object which received the signal
- error (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() and- Infinity.NameResolver.get_port() can be called to obtain the resolved addresses.
- name_resolver (
Property Details¶
- 
Infinity.NameResolver.props.hostname¶
- Name: - hostname- Type: - str- Default Value: - None- Flags: - READABLE,- WRITABLE,- CONSTRUCT- The hostname to be looked up 
- 
Infinity.NameResolver.props.io¶
- Name: - io- Type: - Infinity.Io- Default Value: - None- Flags: - READABLE,- WRITABLE,- CONSTRUCT- I/O handler