Getting Local machine IP address

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chakravarti Mukesh

    #1

    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


  • Markus Stoeger

    #2
    Re: Getting Local machine IP address

    Chakravarti Mukesh wrote:[color=blue]
    > Hi all,
    >
    > I need to know the IP address of the machine where the application is
    > running. How can I get this?[/color]

    Something like:

    string hostname = Dns.GetHostName ();

    IPHostEntry h = Dns.Resolve(hos tname);

    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

    Comment

    Working...