HostEntry

In this chapter you will learn:

  1. Get Address List from HostEntry

Get Address List from HostEntry

using System;// j  a  v a2 s. c  om
using System.Net;

class MainClass
{
    public static void Main(string[] args) 
    {
        foreach (string comp in args) 
        {
            try
            {
                IPAddress[] addresses = Dns.GetHostEntry(comp).AddressList;

                foreach (IPAddress address in addresses)
                {
                    Console.WriteLine("{0} = {1} ({2})", 
                        comp, address, address.AddressFamily);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0} = Error ({1})", comp, ex.Message);
            }
        }
    }
}

Next chapter...

What you will learn in the next chapter:

  1. DNS Name and Its IPHostEntry
  2. Get DNS host name
  3. Resolve a Host name
Home » C# Tutorial » Network
Cookie
CredentialCache
HostEntry
IPHostEntry
IP address from host name
IPEndPoint from IPAddress
IPEndPoint Port
IPEndPoint properties
IPHostEntry
IP Address Parser
Predefined IP Address
NetworkCredential
Ping
Udp Client
Socket connection
Socket creation
Socket sendTo
TcpClient
TcpListener
UdpClient Receive
UdpClient Sending
Uri
WebClient
Response Headers
WebProxy
WebRequest