Pinging on a subnet

m7j4p7

Regular
Joined
Nov 16, 2003
Messages
54
Hi,

I have a few problems which are all connected. I am writing some software for my school - some of the things this software has to do is to display a list of all the computers in the room which are currently switched on. Each of our ICT computers has an IP Address 192.168.13?.xxx where 130 will be one room, 131 another etc. and the computer could have any value for xxx.

For example, the computers in ICT1 have IP Addresses:
192.168.130.001
192.168.130.002
192.168.130.003...........

So, what I want to do is find the current IP address of the computer running the program and then ping all the addresses in the subnet (i.e. 192.168.13?.xxx) and then tell me which IP Addresses existed (I can get the proper NetBEUI name myself)

Is this possible?
:) Mike :)
 
Hi,

as I'm not having a VS.net near :( so the code is not tested.
Visual Basic:
Sub ReturnActivePCs()
Dim ip As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName())
Dim sIP, sreturn  as String
Dim i as Integer
For i = 0 to 255
   sIP = ip.AddressList(0).ToString.Split(".")(0) + "." + _
            ip.AddressList(0).ToString.Split(".")(1) + "." + _
            ip.AddressList(0).ToString.Split(".")(2) + "." + i.tostring
   if Me.Ping(sIP) Then
      sreturn += sIP + vbCrlf 
   end if
Next
Msgbox(sreturn)
End Sub

Protected Function Ping(sIP as String) as Boolean
   'try getting the NeBEUI-Name at this point -> if a name exists
   'return true, else or error return false
End Function

Hope this does the trick. Let me know if not.

Voca
 
Sorry. I meant that I can retrieve the NetBEUI name of the local machine. Could you put in the code which checks the NetBEUI name of the remote IP Address?
 
Back
Top