/// <summary> /// The <c>GetHostName</c> method queries a DNS server to resolve the hostname of the <paramref name="address"/> via reverse lookup. /// </summary> /// <param name="query">The <see cref="IDnsQuery"/> instance.</param> /// <param name="address">The <see cref="IPAddress"/> to resolve.</param> /// <returns> /// The hostname if the reverse lookup was successful or <c>null</c>, in case the host was not found. /// If <see cref="ILookupClient.ThrowDnsErrors"/> is set to <c>true</c>, this method will throw an <see cref="DnsResponseException"/> instead of returning <c>null</c>! /// </returns> /// <exception cref="ArgumentNullException">If <paramref name="address"/>is null.</exception> /// <exception cref="DnsResponseException">If no host has been found and <see cref="ILookupClient.ThrowDnsErrors"/> is <c>true</c>.</exception> public static string GetHostName(this IDnsQuery query, IPAddress address) { if (query == null) { throw new ArgumentNullException(nameof(query)); } if (address == null) { throw new ArgumentNullException(nameof(address)); } var result = query.QueryReverse(address); return(GetHostNameAsyncProcessResult(result)); }