locked
Retrieve current active connection (GPRS, WIFi) IP address of device RRS feed

  • Question

  • I want to know, how can I retrieve an IP address of active connection to internet.

     

    Thursday, December 22, 2005 3:48 PM

Answers

  • here are some methods I use to help:

    static public string[] IPAddress(){
    String strHostName = System.Net.Dns.GetHostName();
    // Then using host name, get the IP address list..
    IPHostEntry ipEntry = System.Net.Dns.GetHostByName(strHostName);
    IPAddress[] addr = ipEntry.AddressList;
    string[] IPArray = new string[ipEntry.AddressList.Length ];
    for (int i = 0; i < addr.Length; i++){
    IPArrayIdea = addrIdea.ToString();
    }
    return IPArray;
    }

    static public bool IsConnected(){
    bool Connected=false;
    string[] IPArray = IPAddress();
    if ( IPArray[0].CompareTo("127.0.0.1") != 0)
    Connected=
    true;
    return Connected;
    }

    Thursday, December 22, 2005 4:30 PM