So I have an IP Camera that has information I want (date, firmware version, etc) and each piece of information is grabbed by going to a Http.GetResponse() from an http URL, and getting an XML responding string. For example, "http://" & ip & "/System/Audio/Channels" gives you a string about its audio channels.
I need a lot of information, but the device doesn't have a URL to list all the items I need, so I repeat this process for each device with x number of item specific URLs. Here's a code snippet of using just one URL:
Dim RespStr As String = "http://" & ip & "/System/Audio/Channels"
'Open Request...
Dim HttpReq As Net.HttpWebRequest = Nothing
Try
'create request object
HttpReq = CType(Net.WebRequest.Create(ReqStr), Net.HttpWebRequest)
'set the username and password
HttpReq.Credentials = New Net.NetworkCredential(camera.Username, camera.Password)
'set method
HttpReq.Method = "GET"
'disable expect-100-continue
HttpReq.ServicePoint.Expect100Continue = False
'timeout
HttpReq.Timeout = 1000 * 2
Catch ex As Exception
End Try
'Open Response...
Dim HttpResp As Net.HttpWebResponse = Nothing
Dim HttpStatus As Net.HttpStatusCode = Nothing
Try
'get the response
HttpResp = CType(HttpReq.GetResponse(), Net.HttpWebResponse)
'verify the response
HttpStatus = HttpResp.StatusCode
If HttpStatus <> Net.HttpStatusCode.OK Then
'error
End If
'do stuff to process xml string
Catch ex As Exception
End Try
Obviously, after the 10th time in a loop for a specific URL, you start to get slow and repetitive.
Is there a way to tell vb.net in a quicker way to go to url1, url2, url3 (all similar to the example I mention above) and concatenate all the string responses in one network attempt? Possibly even at once since it's the same IP Address? Then I can just process it on my end versus over the network.