Public Function getheaders(ByVal add As String) As String
Dim req As WebRequest = WebRequest.Create("http://" & add)
req.Timeout = 2000
Try
Using response As WebResponse = req.GetResponse()
Dim aa As String = response.Headers("WWW-Authenticate")
Return aa
End Using
Catch ex As WebException
Using response As WebResponse = ex.Response
If ex.Status.ToString = "Timeout" Then
Return "none"
Else
Try
Dim aa As String = response.Headers("WWW-Authenticate")
Catch exa As Exception
Return "none"
End Try
End If
End Using
End Try
End Function
//////////////////// CREATIN THREADS ///////////////////////
For i = 0 To 255
Dim t As Thread = New System.Threading.Thread(New ParameterizedThreadStart(AddressOf getheaders))
t.IsBackground = True
t.Start("192.168.1." & ai.ToString)
Next
这工作正常,但是当所有线程都完成后,我无法再使用互联网,直到等待 5 分钟或修复我的连接
错误在哪里或有其他方法吗?