Visual Basic .NET Forums  

Go Back   Visual Basic .NET Forums > Components & Controls > Net / Sockets

Net / Sockets Components for network and related use

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-23-2008, 10:44 PM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Sep 2008
Posts: 3
Reputation: 0
_powerade_ is on a distinguished programming path ahead
Default Find names on devices in a network

Hi,

I'm currently working on an application that first pings and then, if something "pings back", checks the ip-address using the GetHostEntry statement. If a device is connected at ex. IP 192.168.1.50, it pops up on a list.

But I was wondering... Is it possible to get the name of that device? GetHostEntry only gives me the IP-address (unless its a computer, then the computer name pops up) if it find a router, modem, a mobile device etc...

For example: I have a dreambox connected on my network. Is there a way to get the name of the dreambox when i know its ip??? Or my Nokia? Or my wireless printer???

I'm uploading a picture of the application so you might better understand what i mean.

PS: The text in the application is in Norwegian...
Attached Images
File Type: jpg pinger, eksempel.jpg (57.0 KB, 33 views)
__________________
best regards _ powerade_
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 09-24-2008, 9:07 AM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 36
Posts: 9,163
Reputation: 1079
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

There could possibly be other ways and information when DNS host name is not available, but these could also mean more device specific interfacing. One global option is to get the MAC address, the first 3 bytes of these 6 is something called OUI (Organizationally Unique Identifier) and there exist a public list where you can at least find out which manufacturer produced the NIC, the other 3 bytes probably only each manufacturer know what means. Here is an example I have tested and which worked, you need this declaration:
Quote:
Private Declare Function SendARP Lib "iphlpapi.dll" (ByVal DestIP As Integer, ByVal SrcIP As Integer, ByRef pMacAddr As Long, ByRef PhyAddrLen As Integer) As Integer
The OUI list can be downloaded from IEEE.org.

Sample code to get MAC and OUI:
Code:
Dim ip As Integer = CInt(Net.IPAddress.Parse("192.123.45.67").Address)
Dim mem As Long
Dim ret As Integer = SendARP(ip, 0, mem, 6)
Dim ab() As Byte = BitConverter.GetBytes(mem)
Dim OUI As String = BitConverter.ToString(ab, 0, 3)
Nevermind the Address obsolete warning, also Vista runs IP4 compatibility translation.

With the OUI string you can search the text file or create yourself a smaller lookup table from it. When successful it is for example more useful to know this manufacturer name "CANON INC." than only the IP.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-25-2008, 7:44 AM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Sep 2008
Posts: 3
Reputation: 0
_powerade_ is on a distinguished programming path ahead
Default

Thanks a lot JohnH

This solved the problem.
__________________
best regards _ powerade_
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-03-2009, 11:04 PM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Mar 2009
Posts: 6
Reputation: 0
alienation is on a distinguished programming path ahead
Cool Re: Almost same problem

i have a question which may lead to another question, but here's the first...
how can i get the name of the computer/machine using IP address

ex.
the computer's name is alien with ip address 192.168.0.10
now i have a program which pings the network

Try
Dim IncreaseValue As Integer = 1
Dim Ping As New Ping
Dim PingOptions As New PingOptions
PingOptions.Ttl = 64
Dim PingRep As PingReply

While (IncreaseValue <= 256)
Dim IPAddPC = IpAddressPopulate & IncreaseValue.ToString

PingRep = Ping.Send(IPAddPC, 10)
TextBox1.AppendText(PingRep.Status.ToString & " - " & IPAddPC & vbCrLf)
If PingRep.Status = IPStatus.Success Then
ListBox1.Items.Add(IpAddressPopulate & IncreaseValue) ' & " - Computer responded.")
Else
ListBox1.Items.Add(IpAddressPopulate & IncreaseValue) '& " - Computer did not respond.")
End If
IncreaseValue += 1
End While
Catch ex As Exception

End Try

I have another listbox which lists all the ip address that respond to ping.
My problem now is how to retrieve the name of the computers/machines using that IP address. I did use the System.Net.Dns.GetHostEntry(listbox1.selecteditem. tostring).HostName but it returns the value of the ip address and not the name of the computer...

inside the network we also have some network printers that i must also get the information...

kindly help pls...
__________________
"...THe TeLePHoNe NuMBeR u DiaLLeD iS UnDeRGRouND... PLeaSe TRY uR CaLL NeVeR..."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-03-2009, 11:17 PM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Mar 2009
Posts: 6
Reputation: 0
alienation is on a distinguished programming path ahead
Default

follow-up:
i use this to get the information using the IP address

Dim co As New ConnectionOptions()
Dim ms As New System.Management.ManagementScope("\\" & Name & "\root\cimv2", co)
Dim oqProcessor = New System.Management.ObjectQuery("SELECT * FROM Win32_Processor")
Dim queryProcessor = New ManagementObjectSearcher(ms, oqProcessor)
Dim queryCollectionProcessor = queryProcessor.[Get]()

using the above code, i could get the information of the computers, however, i could not get the names of the machines(printer, access point)
__________________
"...THe TeLePHoNe NuMBeR u DiaLLeD iS UnDeRGRouND... PLeaSe TRY uR CaLL NeVeR..."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 03-03-2009, 11:23 PM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Mar 2009
Posts: 6
Reputation: 0
alienation is on a distinguished programming path ahead
Default

i also tried the Win32_NetworkAdapter (just a little thought: i thought all machines have this property ) but to no avail...
__________________
"...THe TeLePHoNe NuMBeR u DiaLLeD iS UnDeRGRouND... PLeaSe TRY uR CaLL NeVeR..."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 03-03-2009, 11:35 PM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Mar 2009
Posts: 6
Reputation: 0
alienation is on a distinguished programming path ahead
Default

another follow-up, i hope this will be the last follow-up...

another thing inside our network, we have computers that have different operating system... for sure i could ping them but how can i get them name and information...???

i'm very sorry for the readers here, im just a newbie so please bear with me...
__________________
"...THe TeLePHoNe NuMBeR u DiaLLeD iS UnDeRGRouND... PLeaSe TRY uR CaLL NeVeR..."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 03-04-2009, 7:00 AM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Sep 2008
Posts: 3
Reputation: 0
_powerade_ is on a distinguished programming path ahead
Default

Hi, try this:

Code:
Imports System.Net
Code:
Dim hostNameOrAddress As String = YourIPadress
Dim returnValue As IPHostEntry

Try
   returnValue = Dns.GetHostEntry(hostNameOrAddress)

   MessageBox.Show(returnValue.HostName())

Catch ex As Exception
   MessageBox.Show(ex.Message)

End Try
__________________
best regards _ powerade_

Last edited by _powerade_; 03-04-2009 at 7:07 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 03-10-2009, 11:44 PM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Mar 2009
Posts: 6
Reputation: 0
alienation is on a distinguished programming path ahead
Cool

Quote:
Originally Posted by _powerade_ View Post
Hi, try this:

Code:
Imports System.Net
Code:
Dim hostNameOrAddress As String = YourIPadress
Dim returnValue As IPHostEntry

Try
   returnValue = Dns.GetHostEntry(hostNameOrAddress)

   MessageBox.Show(returnValue.HostName())

Catch ex As Exception
   MessageBox.Show(ex.Message)

End Try


thanks for your reply. unfortunately, when i tried this code that you had given, it only returns the given ip address. what i needed is that, if that ip address was assigned to a, for example, a network printer or a router, it will display, either the name of the router or some kind of description.

thanks anyway for the reply. it will be of useful future reference.
__________________
"...THe TeLePHoNe NuMBeR u DiaLLeD iS UnDeRGRouND... PLeaSe TRY uR CaLL NeVeR..."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 03-11-2009, 6:32 AM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 36
Posts: 9,163
Reputation: 1079
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

alienation, did you read post 2 before posting in this thread?
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 8:59 PM.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0


For advertising opportunities click here.