Phreak
Regular
Can anyone tell me how to quickly detect how many machines are on a particular subnet? Say I want to scan the network address 192.168.1.0 for all systems on that network/subnet. Right now I'm using a timer that goes off every 1ms. Here is the code I'm using:
Right now it's taking forever to detect the machines, what I really want to know is if a machine is NOT at a specific address, to just skip it right away and move on to the next address. Because now I'm waiting for it to timeout which takes forever.
Thanks.
Visual Basic:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
strFixedNetAddr = IP
If iCounter < 255 Then
bIPScan = True
iCounter = iCounter + 1
strFixedNetAddr = strFixedNetAddr & iCounter
frmProgress.Show()
frmProgress.ProgressBar1.Value = ((iCounter / 255) * 100)
Try
tcpClient.Connect(strFixedNetAddr, 27960)
Catch ex As System.Exception
If ex.Message.ToString = "No connection could be made because the target machine actively refused it" Then
arrIPsToSend(iIPCounter) = strFixedNetAddr
iIPCounter += 1
Else
'no machine found so continue
End If
'MsgBox(arrIPsToSend(iIPCounter))
lblFound.Text = iIPCounter
End Try
Else
'we've sent 255 packets, and are done waiting.
bIPScan = False
iCounter = 0
Timer1.Enabled = False
End If
btnSend.Enabled = True
End Sub
Right now it's taking forever to detect the machines, what I really want to know is if a machine is NOT at a specific address, to just skip it right away and move on to the next address. Because now I'm waiting for it to timeout which takes forever.
Thanks.