Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 136,099 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,642 people online right now. Registration is fast and FREE... Join Now!




Getting a remote Hostname

 
Reply to this topicStart new topic

Getting a remote Hostname

itpro4470
22 Nov, 2007 - 01:56 PM
Post #1

D.I.C Head
Group Icon

Joined: 17 Jun, 2007
Posts: 120



Thanked: 1 times
Dream Kudos: 25
My Contributions
I am writing an IP scanner which will return the ping time in ms and the hostname. I haven't been able to get the hostname no matter how hard I try. If I use Dns.GetHostEntry(ipAddress).Hostname I just get the ip address and I get the same results when using the depreciated function gethostbyaddress. please help.
User is online!Profile CardPM
+Quote Post

Jayman
RE: Getting A Remote Hostname
22 Nov, 2007 - 03:25 PM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,919



Thanked: 42 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
Works for me:
CODE

MessageBox.Show(Dns.GetHostEntry("207.46.193.254").HostName)


Maybe try getting the Hostname by passing in the IP address into the GetHostEntry method of the DNS class in this way.
CODE

Dim hostIp As IPHostEntry = Dns.GetHostEntry("207.46.193.254")
MessageBox.Show(hostIp.HostName)

You could also pass in the site address rather than the IP address.
CODE

Dim hostIp As IPHostEntry = Dns.GetHostEntry("www.microsoft.com")
MessageBox.Show(hostIp.HostName)

User is offlineProfile CardPM
+Quote Post

itpro4470
RE: Getting A Remote Hostname
23 Nov, 2007 - 07:12 AM
Post #3

D.I.C Head
Group Icon

Joined: 17 Jun, 2007
Posts: 120



Thanked: 1 times
Dream Kudos: 25
My Contributions
Thats what I had but I wasn't scanning anything outside of my local netwok when I did a short scan on my ISPs IP addresses I got the hostnames. I found out what I'm looking for is to find the netBIOS name of a remote computer I have been searching all over with google, yahoo etc but I have only found out how to do this for the local machine.
User is online!Profile CardPM
+Quote Post

itpro4470
RE: Getting A Remote Hostname
23 Nov, 2007 - 06:13 PM
Post #4

D.I.C Head
Group Icon

Joined: 17 Jun, 2007
Posts: 120



Thanked: 1 times
Dream Kudos: 25
My Contributions
avatar test
User is online!Profile CardPM
+Quote Post

snoj
RE: Getting A Remote Hostname
23 Nov, 2007 - 06:18 PM
Post #5

$Null
Group Icon

Joined: 31 Mar, 2003
Posts: 3,304



Thanked: 6 times
Dream Kudos: 700
My Contributions
That's because netbios names are only for local networks.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 08:43PM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month