K
Kent Briggs
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)
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)