Der Code geht nahtlos weiter. Ich musste es trennen wegen der 5KB-Grenze.
'**********************************
Private Class PingAsyncArea
Friend Sub StartTestArea(ByVal timeout As Integer)
Dim ipAddress As String
For n1 As Integer = 1 To 2
For n2 As Integer = 1 To 255
Dim test As PingAsync
ipAddress = "192.168." & n1 & "." & n2
test = New PingAsync(ipAddress, timeout)
AddHandler test.PingComplete, AddressOf PingComplete
Next n2
Next n1
Return
End Sub
Friend Sub StartTestArea(ByVal n1Start As Integer, ByVal n1End As _
Integer, ByVal timeout As Integer)
Dim ipAddress As String
For n1 As Integer = n1Start To n1End
For n2 As Integer = 1 To 255
Dim test As PingAsync
ipAddress = "192.168." & n1 & "." & n2
test = New PingAsync(ipAddress, timeout)
AddHandler test.PingComplete, AddressOf PingComplete
Next n2
Next n1
Return
End Sub
Friend Sub StartTestArea(ByVal n1Start As Integer, ByVal n1End As _
Integer, ByVal n2Start As Integer, ByVal n2End As Integer, ByVal _
timeout As Integer)
Dim ipAddress As String
For n1 As Integer = n1Start To n1End
For n2 As Integer = n2Start To n2End
Dim test As PingAsync
ipAddress = "192.168." & n1 & "." & n2
test = New PingAsync(ipAddress, timeout)
AddHandler test.PingComplete, AddressOf PingComplete
Next n2
Next n1
Return
End Sub
Private Sub PingComplete(ByVal sender As Object, ByVal e As _
System.Net.NetworkInformation.PingCompletedEventArgs)
If e.Reply.Status = IPStatus.Success Then
mArrayNrIP += 1
Array.Resize(mArrayIP, mArrayIP.Length + 1)
mArrayIP(mArrayNrIP) = e.Reply.Address.ToString
mArrayNrDelay += 1
Array.Resize(mArrayDelay, mArrayDelay.Length + 1)
mArrayDelay(mArrayNrDelay) = e.Reply.RoundtripTime
End If
CType(sender, IDisposable).Dispose()
End Sub
'**********************************
Private Class PingAsync
Private WithEvents m_Ping As New Ping
Public Event PingComplete(ByVal sender As Object, ByVal e As _
System.Net.NetworkInformation.PingCompletedEventArgs)
Public Sub New(ByVal ip As String, ByVal timeout As Integer)
m_Ping.SendAsync(ip, timeout, ip)
End Sub
Private Sub m_PingComplete(ByVal sender As Object, ByVal e As _
System.Net.NetworkInformation.PingCompletedEventArgs) Handles _
m_Ping.PingCompleted
RaiseEvent PingComplete(sender, e)
End Sub
End Class 'PingAsync
End Class 'PingArea
End Module 'DoPingArea Achso...nicht vergessen:
Imports System.Net
Imports System.Net.NetworkInformation
Beitrag wurde zuletzt am 04.07.08 um 10:30:28 editiert. |