Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all.

I'm writing a program to do a listing of all the computers on a network. I managed to get the IP's but now I need to resolve the host name. My code works to resolve Windows PC's and server's host names but it does not work to resolve non Windows machines.

Here is my code:
VB
Dim host As System.Net.IPHostEntry
host = System.Net.Dns.GetHostByAddress("IP address")
MsgBox(host.HostName)


Thanx in advance
Posted
Comments
Sandeep Mewara 13-Oct-10 7:36am    
Any error?

You can use Dns.GetHostEntry to retrieve this information. It works both ways, meaning you can give an IP and get the hostname or supply the hostname to get the IP. Have a look at the link below.

http://msdn.microsoft.com/en-us/library/ms143998.aspx[^]

Good luck!
 
Share this answer
 
Comments
Dalek Dave 14-Oct-10 3:34am    
Good Call
I have tried using Dns.GetHostEntrybut but I get the same problem.

I use Try-Catch and get this message: "The requested name is valid, but no data of the requested type was found"
 
Share this answer
 
Comments
Simon_Whale 13-Oct-10 10:56am    
again how doesn't it work? any error messages?
I'm sorry but I don't know what you mean :(
Like I said I use the Try-Catch and on error show the error. The msgbox only display this: "The requested name is valid, but no data of the requested type was found"

According to me it sees that the host is on the network but it can't get the host name. This is only the case with Linux machines.
 
Share this answer
 
Comments
E.F. Nijboer 14-Oct-10 4:13am    
You should add comments instead of answers as comments because I don't get notified. I just looked because Dalek Dave voted nicely on my answer.
You can use Samba on your Linux machine to do that. Look at this link for more info:
http://www.terminally-incoherent.com/blog/2007/10/03/access-linux-workstation-by-hostname-on-a-windows-network/
wikus70 14-Oct-10 4:49am    
Sorry about that. I'm still kind of new to this site and asking questions.
We are running Samba on one of our Linux Servers but I didn't notice that it returned the Host name. I just thought since the one Linux Server doesn't work that non of them will work.
I think installing Samba on all the Linux servers will work.
Thank you very much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900