Dns.GetHostByAddress Method

Definition

Gets DNS host information for an IP address. These methods are now obsolete.

Overloads

GetHostByAddress(IPAddress)
Obsolete.
Obsolete.
Obsolete.

Creates an IPHostEntry instance from the specified IPAddress.

GetHostByAddress(String)
Obsolete.
Obsolete.
Obsolete.

Creates an IPHostEntry instance from an IP address.

GetHostByAddress(IPAddress)

Source:
Dns.cs
Source:
Dns.cs
Source:
Dns.cs

Caution

GetHostByAddress is obsoleted for this type, please use GetHostEntry instead. https://go.microsoft.com/fwlink/?linkid=14202

Caution

GetHostByAddress has been deprecated. Use GetHostEntry instead.

Caution

GetHostByAddress is obsoleted for this type, please use GetHostEntry instead. http://go.microsoft.com/fwlink/?linkid=14202

Creates an IPHostEntry instance from the specified IPAddress.

[System.Obsolete("GetHostByAddress is obsoleted for this type, please use GetHostEntry instead. https://go.microsoft.com/fwlink/?linkid=14202")]
public static System.Net.IPHostEntry GetHostByAddress (System.Net.IPAddress address);
[System.Obsolete("GetHostByAddress has been deprecated. Use GetHostEntry instead.")]
public static System.Net.IPHostEntry GetHostByAddress (System.Net.IPAddress address);
[System.Obsolete("GetHostByAddress is obsoleted for this type, please use GetHostEntry instead. http://go.microsoft.com/fwlink/?linkid=14202")]
public static System.Net.IPHostEntry GetHostByAddress (System.Net.IPAddress address);
public static System.Net.IPHostEntry GetHostByAddress (System.Net.IPAddress address);

Parameters

address
IPAddress

An IPAddress.

Returns

An IPHostEntry instance.

Attributes

Exceptions

address is null.

An error is encountered when resolving address.

Examples

The following example creates a IPHostEntry from an IPAddress.

 try
 {
    IPAddress hostIPAddress = IPAddress.Parse(IpAddressString);
    IPHostEntry hostInfo = Dns.GetHostByAddress(hostIPAddress);
    // Get the IP address list that resolves to the host names contained in
    // the Alias property.
    IPAddress[] address = hostInfo.AddressList;
    // Get the alias names of the addresses in the IP address list.
    String[] alias = hostInfo.Aliases;

    Console.WriteLine("Host name : " + hostInfo.HostName);
    Console.WriteLine("\nAliases :");
    for(int index=0; index < alias.Length; index++) {
      Console.WriteLine(alias[index]);
    }
    Console.WriteLine("\nIP address list : ");
    for(int index=0; index < address.Length; index++) {
       Console.WriteLine(address[index]);
    }
 }
 catch(SocketException e)
 {
Console.WriteLine("SocketException caught!!!");
    Console.WriteLine("Source : " + e.Source);
    Console.WriteLine("Message : " + e.Message);
 }
 catch(FormatException e)
 {
Console.WriteLine("FormatException caught!!!");
    Console.WriteLine("Source : " + e.Source);
    Console.WriteLine("Message : " + e.Message);
 }
 catch(ArgumentNullException e)
 {
Console.WriteLine("ArgumentNullException caught!!!");
    Console.WriteLine("Source : " + e.Source);
    Console.WriteLine("Message : " + e.Message);
 }
 catch(Exception e)
 {
     Console.WriteLine("Exception caught!!!");
     Console.WriteLine("Source : " + e.Source);
     Console.WriteLine("Message : " + e.Message);
 }

Remarks

Note

This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing in the .NET Framework.

Applies to

.NET 9 and other versions
Product Versions (Obsolete)
.NET (Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9)
.NET Framework 1.1 (2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1)
.NET Standard (2.0, 2.1)

GetHostByAddress(String)

Source:
Dns.cs
Source:
Dns.cs
Source:
Dns.cs

Caution

GetHostByAddress is obsoleted for this type, please use GetHostEntry instead. https://go.microsoft.com/fwlink/?linkid=14202

Caution

GetHostByAddress has been deprecated. Use GetHostEntry instead.

Caution

GetHostByAddress is obsoleted for this type, please use GetHostEntry instead. http://go.microsoft.com/fwlink/?linkid=14202

Creates an IPHostEntry instance from an IP address.

[System.Obsolete("GetHostByAddress is obsoleted for this type, please use GetHostEntry instead. https://go.microsoft.com/fwlink/?linkid=14202")]
public static System.Net.IPHostEntry GetHostByAddress (string address);
[System.Obsolete("GetHostByAddress has been deprecated. Use GetHostEntry instead.")]
public static System.Net.IPHostEntry GetHostByAddress (string address);
[System.Obsolete("GetHostByAddress is obsoleted for this type, please use GetHostEntry instead. http://go.microsoft.com/fwlink/?linkid=14202")]
public static System.Net.IPHostEntry GetHostByAddress (string address);
public static System.Net.IPHostEntry GetHostByAddress (string address);

Parameters

address
String

An IP address.

Returns

An IPHostEntry instance.

Attributes

Exceptions

address is null.

An error is encountered when resolving address.

address is not a valid IP address.

Remarks

Note

This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing in the .NET Framework.

Applies to

.NET 9 and other versions
Product Versions (Obsolete)
.NET (Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9)
.NET Framework 1.1 (2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1)
.NET Standard (2.0, 2.1)