System.Net.IPHostEntry Class

public class IPHostEntry

Base Types

Object
  IPHostEntry

Assembly

System

Library

Networking

Summary

Provides a container class for Internet host address information.

Description

The IPHostEntry class associates a Domain Name System (DNS) host name with an array of aliases and an array of matching IP addresses.

Example

The following example queries the DNS database for information on the host "www.contoso.com" and displays the information in the returned IPHostEntry instance.

using System;
using System.Net;

public class IPHostEntryTest {
 public static void Main() {
 
 IPHostEntry hostInfo = Dns.GetHostByName("www.contoso.com");

 string[] aliases = hostInfo.Aliases;
 IPAddress[] addresses = hostInfo.AddressList;
 
 Console.WriteLine("The host name is: {0}", hostInfo.HostName);

 for(int x = 0; x < aliases.Length; x++)
 Console.WriteLine("Alias {0} == {1}", aliases[x], addresses[x]);
 }
}
   
The output is

The host name is: contoso.com

Alias www.contoso.com == 207.46.230.186

See Also

System.Net Namespace

Members

IPHostEntry Constructors

IPHostEntry Constructor

IPHostEntry Properties

IPHostEntry.AddressList Property
IPHostEntry.Aliases Property
IPHostEntry.HostName Property


IPHostEntry Constructor

public IPHostEntry();

Summary

Constructs a new instance of the IPHostEntry class.

See Also

System.Net.IPHostEntry Class, System.Net Namespace

IPHostEntry.AddressList Property

public IPAddress[] AddressList { get; set; }

Summary

Gets or sets a list of IP addresses associated with a host.

Property Value

A IPAddress array containing IP addresses that resolve to the host names contained in the System.Net.IPHostEntry.Aliases property.

See Also

System.Net.IPHostEntry Class, System.Net Namespace

IPHostEntry.Aliases Property

public string[] Aliases { get; set; }

Summary

Gets or sets a list of aliases associated with a host.

Property Value

A String array containing DNS names that resolve to the IP addresses in the System.Net.IPHostEntry.AddressList property.

See Also

System.Net.IPHostEntry Class, System.Net Namespace

IPHostEntry.HostName Property

public string HostName { get; set; }

Summary

Gets or sets the DNS name of the host.

Property Value

A String containing the DNS host name that corresponds to the address and alias information contained in the current instance.

Description

[Note: The System.Net.IPHostEntry.HostName property contains the primary host name for a server. If the DNS entry for the host defines additional aliases, they are available via the System.Net.IPHostEntry.Aliases property.]

See Also

System.Net.IPHostEntry Class, System.Net Namespace