System.Net.Dns????

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

Hi.. I don't get it.... this procedure is obsolete.. that is obsolete....
I am trying to rewrite a program i wrote in vb 6 years ago
Dim hostIPAddress As IPAddress = IPAddress.Parse(Me.txtLookupHostIP.Text)

Dim hostinfo As IPHostEntry =
System.Net.Dns.GetHostEntry(hostIPAddress.ToString)



?system.Net.Dns.Resolve(hostIPAddress.ToString)

{System.Net.IPHostEntry}

AddressList: {Length=1}

Aliases: {Length=0}

HostName: "ComputerName.DomainName"



?System.Net.Dns.GetHostEntry(hostIPAddress.ToString)

Run-time exception thrown : System.Net.Sockets.SocketException - No such
host is known

warnings say not to use resolve, but to use GetHostEntry

I am just trying to pass an IP address and get the Host name... either from
the internet or local network.. or pass the host name and get the ip..
 
I am just trying to pass an IP address and get the Host name... either from
the internet or local network.. or pass the host name and get the ip..

Using VB 2005, i can get hostname simply by using:
System.Net.Dns.GetHostName.ToString

And getting IP address by passing hostname can be done using:
'-----------------------------------
Imports System.Net.Dns
Imports System.Net

Dim hostname As String
hostname = GetHostName.ToString
For Each ip As IPAddress In _
GetHostEntry(hostname).AddressList
' Return IP address in messagebox
MsgBox(ip.ToString)
Next
'------------------------------

Hope this helps,

Onur Güzel
 
ok, now what about passing an ip address?
MsgBox(GetHostEntry(Me.txtLookupHostIP.Text).HostName)

me.txtLookupHostIP.text = 192.168.1.1 This address is assigned from a dhcp
server on the local network....

and is listed in the dns.. and I get "No such host is known"



I am just trying to pass an IP address and get the Host name... either
from
the internet or local network.. or pass the host name and get the ip..

Using VB 2005, i can get hostname simply by using:
System.Net.Dns.GetHostName.ToString

And getting IP address by passing hostname can be done using:
'-----------------------------------
Imports System.Net.Dns
Imports System.Net

Dim hostname As String
hostname = GetHostName.ToString
For Each ip As IPAddress In _
GetHostEntry(hostname).AddressList
' Return IP address in messagebox
MsgBox(ip.ToString)
Next
'------------------------------

Hope this helps,

Onur Güzel
 
ok, now what about passing an ip address?
MsgBox(GetHostEntry(Me.txtLookupHostIP.Text).HostName)

me.txtLookupHostIP.text = 192.168.1.1   This address is assigned froma dhcp
server on the local network....

and is listed in the dns.. and I get "No such host is known"




Using VB 2005, i can get hostname simply by using:
System.Net.Dns.GetHostName.ToString

And getting IP address by passing hostname can be done using:
'-----------------------------------
Imports System.Net.Dns
Imports System.Net

Dim hostname As String
hostname = GetHostName.ToString
For Each ip As IPAddress In _
GetHostEntry(hostname).AddressList
 ' Return IP address in messagebox
MsgBox(ip.ToString)
Next
'------------------------------

Hope this helps,

Onur Güzel

Well, it seems you want to get host name by passing an IP address and
that can be done using:

Imports System.Net.Dns

' Your computer's LAN IP address
' assigned by your router or LAN device
Dim ip As String = "192.168.1.2"
' that returns my hostname
MsgBox(GetHostEntry(ip).HostName.ToString)

Note: You must pay attention to your firewall installed on your
machine, which may prevent you from retrieving info about your IP
address, and may require to set "trusted" rule or similar manually.
Plus make sure, you're passing correct IP address.

Hope this helps,

Onur Güzel
 
Back
Top