Pinging Network Computers

How to effeciently find computers on the local LAN

Page 1 of 1

0 Replies - 1361 Views - Last Post: 18 May 2008 - 02:34 AM Rate Topic: -----

#1 qqwetiqewq   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 26-September 07

Pinging Network Computers

Posted 18 May 2008 - 02:34 AM

I want to find active computers on the local LAN.
I've written the following code that searches all possible LAN IPs by pinging them.

Public Sub FindPCs()
		Dim NetworkIP As String
		Dim NetIPStub As String
		Dim PCs(255) As String
		Dim mCount As Int16 = 0

		'Get the LAN IP of this computer
		NetworkIP = getNetworkIP().ToString

		'Loop through all IPs assuming subnet
		For i As Int16 = 0 To 255

			'Get the base of the ip, ie. 192.168.x
			NetIPStub = NetworkIP.Substring(0, NetworkIP.LastIndexOf("."))

			'add i to the end, ie. 192.168.x.i
			NetIPStub += "." + i.ToString

			'ping it
			'if successful add to list
			If My.Computer.Network.Ping(NetIPStub, 10) Then
				PCs(mCount) = NetIPStub
				mCount += 1
			End If


		'let me know when done

	End Sub

However this takes ages to process.
Is there a better way?

Thank you.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1