Get local IP on PPC without DNS

  • Thread starter Thread starter jeep
  • Start date Start date
J

jeep

I am trying to provide a list of local IPs on my PPC (WM 2003) for use
in a UDP application. dns seems to be the most common moethod, but it
is not available in the environment. It is likely that there will be a
wifi and bluetooth connection available so I need the user to select
the appropriate IP (likely wifi).
 
jeep said:
I am trying to provide a list of local IPs on my PPC (WM 2003) for use
in a UDP application. dns seems to be the most common moethod, but it
is not available in the environment. It is likely that there will be a
wifi and bluetooth connection available so I need the user to select
the appropriate IP (likely wifi).

wish this could help :)

using System;
using System.Net;

// *usage* Demo '--hostname'

public class Demo
{
public static void Main(string[] argv)
{
try{
if(argv.Length == 0)
return;

IPHostEntry hostInfo = Dns.GetHostByName(argv[0]);
if(hostInfo.AddressList.Length >= 1)
{
Console.WriteLine("{0}", hostInfo.AddressList.Length);
foreach(IPAddress ipa in hostInfo.AddressList)
{
Console.WriteLine("{0}",ipa.ToString());
}
}
} catch(Exception e) { }
}
}
 
That's not a problem. On the PC, the way this specific type of thing is
actually done is *not* with DNS, which is a defined protocol for querying
well-known servers for translations between things like www.microsoft.com
and the IP address where that server can be found. To provide a local list
of mappings on the desktop, you'd use a 'hosts' file. On Windows CE, you
can store something like that in the registry:

HKEY_LOCAL_MACHINE\Comm\Tcpip\Hosts\host name

The settings are documented in MSDN on a page titled "TCP/IPv4 Configurable
Registry Settings".

Paul T.
 
Back
Top