471,347 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,347 software developers and data experts.

Getting Local machine IP address

Hi all,

I need to know the IP address of the machine where the application is
running. How can I get this?

Thanks
Chakravarti Mukesh
Feb 12 '06 #1
1 1662
Chakravarti Mukesh wrote:
Hi all,

I need to know the IP address of the machine where the application is
running. How can I get this?


Something like:

string hostname = Dns.GetHostName();

IPHostEntry h = Dns.Resolve(hostname);

Trace.WriteLine("IP addresses for " + hostname + ":");

foreach (IPAddress ip in h.AddressList) {
Trace.WriteLine(ip);
}

This lists all your local ip addresses (except of 127.0.0.1).

hth,
Max
Feb 12 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Snuffy2 | last post: by
3 posts views Thread by Dan | last post: by
reply views Thread by Ronak mishra | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.