Detect Machines on a Network

Phreak

Well-known member
Joined
Jun 7, 2002
Messages
62
Location
Iowa, United States
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 Im using a timer that goes off every 1ms. Here is the code Im using:

Code:
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
            weve sent 255 packets, and are done waiting.

            bIPScan = False
            iCounter = 0
            Timer1.Enabled = False
        End If

        btnSend.Enabled = True
    End Sub

Right now its 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 Im waiting for it to timeout which takes forever.

Thanks.
 
Back
Top