Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / July 2006

Tip: Looking for answers? Try searching our database.

GetHostEntry

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kent Briggs - 26 Jul 2006 22:29 GMT
I'm trying to get the IP address of a named computer in my local
network. The problem is, my code below only works when my Axim
(WM_Kent1) is cradled and connected via active sync to my desktop
(Dell4600). Then I can enter Dell4600 into the textbox and it returns
two IP's, one for the ActiveSync connection itself (169.254.2.2) and
another for the regular LAN IP (192.168.1.100). So far, so good. But
when I uncradle the Axim (and confirm my Wi-Fi is connected), it stops
working and fires an exception: No such host is known. But I can ping
the Axim by name (WM_Kent1) from the desktop and it sees it wirelessly.
So the desktop can see the Axim but the Axim can't see the desktop. Why
is that?

Dim entry As IPHostEntry = Nothing
Try
    entry = Dns.GetHostEntry(TextBox1.Text)
Catch ex As Exception
    MsgBox(ex.Message)
    Exit Sub
End Try
Dim n As Integer = entry.AddressList.Length
If n = 0 Then
    MsgBox("No IP address found for " & TextBox1.Text)
    Exit Sub
End If
Dim i As Integer
Dim ip As String = entry.HostName & vbCr
For i = 0 To n - 1
    ip = ip & "IP = " & entry.AddressList(i).ToString & vbCr
Next
MsgBox(ip)

Signature

Kent Briggs, kbriggs@spamcop.net
Briggs Softworks, http://www.briggsoft.com

Kent Briggs - 27 Jul 2006 22:41 GMT
> I'm trying to get the IP address of a named computer in my local
> network.

After some experimenting I noticed that Dns.GetHostEntry("Dell4600")
does work if I set my Axim Wi-Fi adapter to "Use specific IP address"
and fill in the IP, mask, and gateway in manually. But I use the same
numbers (192.168.1.2, 255.255.255.0, 192.168.1.1) that it uses when the
setting is "Use server-assigned IP address". So why can't GetHostEntry()
find my other computers on my LAN by name when the IP is server-assigned
since the numbers are all the same anyway?

Signature

Kent Briggs, kbriggs@spamcop.net
Briggs Softworks, http://www.briggsoft.com

Paul G. Tobey [eMVP] - 27 Jul 2006 22:57 GMT
DNS isn't one of those three numbers!  The DNS server address is probably
not being sent by your DHCP server but may be set statically for the
adapter.  So, when you use static addressing, you get the address from the
registry, which is right, and when you use dynamic addressing, you don't get
the DNS server address, so it doesn't work.  At least, that's my first
guess...

Paul T.

>> I'm trying to get the IP address of a named computer in my local network.
>
[quoted text clipped - 5 lines]
> other computers on my LAN by name when the IP is server-assigned since the
> numbers are all the same anyway?
Kent Briggs - 28 Jul 2006 01:19 GMT
> DNS isn't one of those three numbers!  The DNS server address is probably
> not being sent by your DHCP server but may be set statically for the
> adapter.  So, when you use static addressing, you get the address from the
> registry, which is right, and when you use dynamic addressing, you don't get
> the DNS server address, so it doesn't work.  At least, that's my first
> guess...

Yeah, there's a separate tab for name servers (DNS, Alt DNS, WINS, Alt
WINS) which are all blank. A blank DNS appears to be the key here
because when I look in my Axim registry here:

HKLM\Comm\ODIM\TIACXWLN1\Parms\TCPIP

I have the following settings when using a server-assign IP:

DhcpDefaultGateway = 192.168.1.1
DhcpIPAddress = 192.168.1.2
DhcpDNS = 24.93.41.125
DefaultGateway = 0.0.0.0
IpAddress = 0.0.0.0
DNS = (blank)

When I use a static IP, the DefaultGateway and IpAddress get filled in
but the DNS stays blank. So the culprit must be the DhcpDNS value. That
24.93.41.125 number is owned by my ISP and is being fed by my LinkSys
router. And of course my ISP's DNS isn't going to know about the PCs on
my internal LAN.

So is this fixable? I need the Axim to be able to see the outside world
and the other PCs in my LAN without having to use a static IP. I tried
just blanking out the DhcpDNS value in the registry but it had no
immediate affect and was reset when the connection was reset, as expected.

Signature

Kent Briggs, kbriggs@spamcop.net
Briggs Softworks, http://www.briggsoft.com

Paul G. Tobey [eMVP] - 28 Jul 2006 16:58 GMT
Work-aroundable, maybe.  I'm not sure what method is being used when the DNS
server list is empty.  The only real fix I can see is to *have* a DNS server
on your local network that *does* know the name to IP mapping.  It's not
clear to me why it works in the blank case, but something undocumented is
happening under the covers, I think.

Paul T.

>> DNS isn't one of those three numbers!  The DNS server address is probably
>> not being sent by your DHCP server but may be set statically for the
[quoted text clipped - 28 lines]
> just blanking out the DhcpDNS value in the registry but it had no
> immediate affect and was reset when the connection was reset, as expected.
Kent Briggs - 28 Jul 2006 17:19 GMT
> Work-aroundable, maybe.  I'm not sure what method is being used when the DNS
> server list is empty.  The only real fix I can see is to *have* a DNS server
> on your local network that *does* know the name to IP mapping.  It's not
> clear to me why it works in the blank case, but something undocumented is
> happening under the covers, I think.

The problem with that is my particular application will only know the
SSID of the Wi-Fi network and the name of computer on that network to
which it is trying to fetch the IP. It won't know any IPs on the network
in advance except for what the Wi-Fi router is feeding it via DHCP.

Signature

Kent Briggs, kbriggs@spamcop.net
Briggs Softworks, http://www.briggsoft.com

Paul G. Tobey [eMVP] - 28 Jul 2006 17:33 GMT
The WiFi router should be able to be configured with the DNS server it
should pass to an DHCP clients it has.  Alternatively, you should be able to
turn off DHCP on the WiFi router and just have it route DHCP requests to the
wired network it connects with, where you'd have a DHCP server on a desktop
or server machine running.  That would *certainly* be able to be configured
with the right DNS server address and the server itself.

Paul T.

>> Work-aroundable, maybe.  I'm not sure what method is being used when the
>> DNS server list is empty.  The only real fix I can see is to *have* a DNS
[quoted text clipped - 6 lines]
> is trying to fetch the IP. It won't know any IPs on the network in advance
> except for what the Wi-Fi router is feeding it via DHCP.
Kent Briggs - 28 Jul 2006 19:01 GMT
> The WiFi router should be able to be configured with the DNS server it
> should pass to an DHCP clients it has.  Alternatively, you should be able to
> turn off DHCP on the WiFi router and just have it route DHCP requests to the
> wired network it connects with, where you'd have a DHCP server on a desktop
> or server machine running.  That would *certainly* be able to be configured
> with the right DNS server address and the server itself.

Unfortunately in my particular scenario, the Wi-Fi router (which is also
the internet gateway) may be owned by a third party where configuration
changes are not possible.

Signature

Kent Briggs, kbriggs@spamcop.net
Briggs Softworks, http://www.briggsoft.com

Paul G. Tobey [eMVP] - 28 Jul 2006 19:24 GMT
Then you'll have to resolve names by some means other than real DNS.  I
don't know enough about .NET CF to really tell you what to try; you'll have
to browse the class library.

Paul T.

>> The WiFi router should be able to be configured with the DNS server it
>> should pass to an DHCP clients it has.  Alternatively, you should be able
[quoted text clipped - 6 lines]
> the internet gateway) may be owned by a third party where configuration
> changes are not possible.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.