Sunday, January 11, 2009

IP address of your computer or any website tutorial example

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;



using System.Net;



namespace IPAddressApplication

{

class Program

{

static void Main(string[] args)

{

//Get IP info about this computer

//

Console.WriteLine("Local host:");

Console.WriteLine();

string Name = Dns.GetHostName();

Console.WriteLine("\tHost Name: " + Name);

Line();



DisplayHostInfo(Name);

Line();



//Get IP info of an internet address

//

DisplayHostInfo("www.amazon.com");

Line();



Console.ReadKey();

}



static void Line()

{

Console.WriteLine("\t============================================");

}



static void DisplayHostInfo(string Host)

{

IPHostEntry hostStuff;



hostStuff = Dns.GetHostEntry(Host);



// Start displaying info

// DNS name of the host

Console.WriteLine("\tPrimary host name: " + hostStuff.HostName);



// Alias names associated with the host

Console.Write("\tAliases: ");

foreach (string alias in hostStuff.Aliases)

{

Console.WriteLine("\t\t" + alias);

}

Console.WriteLine();



// List of IP addresses associated with the host

// May be IPv4 or IPv6 forms

Console.WriteLine("\tIP Addresses: ");

foreach (IPAddress ip in hostStuff.AddressList)

{

Console.WriteLine("\t\t" + ip.ToString());

}

Console.WriteLine();



}

}

}

0 comments:

Followers

Get our toolbar!

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | JCPenney Coupons