Sunday, 8 May 2011

How to get IP Address of Websites using C#

How to get IP Address of Websites in C# application
In C# with the help of Namespace System.Net.Sockets and System.Net we can build an application through which we can find ID address of the websites.
Program code is given below-
IPHostEntry - Provides a container class for internet host address information .

Dns.GetHostEntry("Hostname")-
Resolve a DNS hostname or IP Address to an System.Net.IPHostEntry instance.

using System;
using System.Net;
using System.Net.Sockets;

class ip
{
     
    public static void Main()
    {
       String HostName ;
       Console.WriteLine("Enter Web Address:");
       HostName = Console.ReadLine();
       Console.WriteLine("Looking up: {0}", HostName);
       IPHostEntry NameToIpAddress;
       NameToIpAddress = Dns.GetHostEntry(HostName);
       int AddressCount = 0;
       foreach (IPAddress Address in NameToIpAddress.AddressList)
       Console.WriteLine("IP Address {0}: {1}", ++AddressCount, Address.ToString());
       Console.ReadLine();
  
        
    }
}
IP Address of Gmail.com
IP Address of Facebook.com
previous

3 comments:

  1. If anyone want to find ip address of any website means try domain to ip converter tool like WhoisXY.com

    ReplyDelete
  2. This C# IP address resolution tutorial is very practical! The code examples for getting IP addresses from hostnames using the Dns class are very clear. I appreciated the error handling approach. For tech professionals in Bangalore looking for quality education, finding the best AI training Center in Electronic City can make a huge difference in career growth. Thanks for sharing this helpful C# networking guide!

    ReplyDelete