B
BogusException
[VB2005]
Overview: I need to generate traffic to a user-defined URL in 2 ways:
connection attempts/second, and # of simultaneous connections. This
isn't the problem, though. I'm just giving you the background.
In the code below, I get 2 responses back, and all others timeout:
Public Class Request
[...]
Public Sub DoRequest(ByVal sURL As String)
Dim URL As String = sURL
Try
Dim request As WebRequest = WebRequest.Create(URL)
iSentTotal = iSentTotal + 1
Dim response As WebResponse = request.GetResponse()
iRecvdTotal = iRecvdTotal + 1
Catch ex As System.Net.WebException
iTimedOutTotal = iTimedOutTotal + 1
Console.WriteLine("Response timed out...")
Catch ex As UriFormatException
MsgBox(" Invalid URL:" & URL.ToString & vbCrLf &
ex.ToString, MsgBoxStyle.Critical)
Catch ex As Exception
MsgBox("Generic Exception:" & vbCrLf & ex.ToString,
MsgBoxStyle.Critical)
Finally
iRequestsTotal = iRequestsTotal + 1
End Try
End Sub
[...]
I call this from the main form with:
If Me.bRunning = True Then
Dim t As New Thread(New ThreadStart(AddressOf DoURL))
t.Priority = Me.ListBox1.SelectedIndex
t.IsBackground = True
t.Start()
End If
...with DoURL looking simply like:
Sub DoURL()
Dim r As New Request
r.DoRequest(txtURL.Text)
End Sub
I can't figure out if the problem is that I can't start a lot of
threads with the same variable name in the main form (t in this case),
or whether the WebRequest and WebResponse routines have some sort of
limitation.
I seem to have no trouble generating outbound requests... I still am
not sure if I can instantiate VB classes with instance names based on
variables. This would be nice! Right now it looks liek I keep making
the same thread instance name, "t", which may be at the root of the
problem. How are threads generated en masse?
TIA!
BogusException
Overview: I need to generate traffic to a user-defined URL in 2 ways:
connection attempts/second, and # of simultaneous connections. This
isn't the problem, though. I'm just giving you the background.
In the code below, I get 2 responses back, and all others timeout:
Public Class Request
[...]
Public Sub DoRequest(ByVal sURL As String)
Dim URL As String = sURL
Try
Dim request As WebRequest = WebRequest.Create(URL)
iSentTotal = iSentTotal + 1
Dim response As WebResponse = request.GetResponse()
iRecvdTotal = iRecvdTotal + 1
Catch ex As System.Net.WebException
iTimedOutTotal = iTimedOutTotal + 1
Console.WriteLine("Response timed out...")
Catch ex As UriFormatException
MsgBox(" Invalid URL:" & URL.ToString & vbCrLf &
ex.ToString, MsgBoxStyle.Critical)
Catch ex As Exception
MsgBox("Generic Exception:" & vbCrLf & ex.ToString,
MsgBoxStyle.Critical)
Finally
iRequestsTotal = iRequestsTotal + 1
End Try
End Sub
[...]
I call this from the main form with:
If Me.bRunning = True Then
Dim t As New Thread(New ThreadStart(AddressOf DoURL))
t.Priority = Me.ListBox1.SelectedIndex
t.IsBackground = True
t.Start()
End If
...with DoURL looking simply like:
Sub DoURL()
Dim r As New Request
r.DoRequest(txtURL.Text)
End Sub
I can't figure out if the problem is that I can't start a lot of
threads with the same variable name in the main form (t in this case),
or whether the WebRequest and WebResponse routines have some sort of
limitation.
I seem to have no trouble generating outbound requests... I still am
not sure if I can instantiate VB classes with instance names based on
variables. This would be nice! Right now it looks liek I keep making
the same thread instance name, "t", which may be at the root of the
problem. How are threads generated en masse?
TIA!
BogusException