lookup_by_address
Description:
[ Version ( since = "2.22" ) ]
public virtual string lookup_by_address (InetAddress address, Cancellable? cancellable = null) throws Error
public virtual string lookup_by_address (InetAddress address, Cancellable? cancellable = null) throws Error
Synchronously reverse-resolves address
to determine its associated hostname.
If the DNS resolution fails, throws (if non-null) will be set to a value from ResolverError.
If cancellable
is non-null, it can be used to cancel the operation, in which case
throws (if non-null) will be set to
g_io_error_cancelled.
Example: Resolver, lookup by address, sync:
public static int main () {
try {
// Output: ``wikipedia-lb.pmtpa.wikimedia.org`` (Wed Oct 24, 20012)
InetAddress address = new InetAddress.from_string ("208.80.152.201");
Resolver resolver = Resolver.get_default ();
string hostname = resolver.lookup_by_address (address, null);
print ("host: %s\n", hostname);
} catch (Error e) {
print ("Error: %s\n", e.message);
}
return 0;
}
valac --pkg gio-2.0 GLib.Resolver.lookup_by_address.vala
Parameters:
this |
a Resolver |
address |
the address to reverse-resolve |
cancellable |
a Cancellable, or null |
Returns:
a hostname (either ASCII-only, or in ASCII-encoded form), or null on error. |