Hi,
Just downloaded the trial version of RealBasic - looks like a great program!
I've been trying to write a simple little Windows XP program that will download
3 URLs in succession, timing each download, and then calculating the throughput
(to check my DSL connection over time). It's been a while since I've written
in BASIC, and I've seem to have gotten stuck on the HTTPSocket class. I've got
a couple questions (with my sample code below):
1) When I call an instance of the HTTPSocket class by dragging the control onto
a window and then calling it, I can't seem to get my custom events to trigger
(like PageReceived). I call it this way: Call http.get (testURL(i),60). The
odd thing is, the events do trigger if I just run http.get (testURL(i)), but
then the first 2 URLs don't download completely .. only the last one. Any way
I can trigger HTTPSocket events and make sure each download runs to completion?
2) How can I pull the bytesReceived and totalBytes values from the
ReceiveProgress event in the HTTPSocket class and bring it into my default
Window method I'm for my execution? I need these to calculated the actual
throughput.
Thanks in advance,
Frank
====================================
Sample Code
====================================
Sub DoDownloads(testURL() as String)
// Variable Declarations
Dim StartTime(3) as integer
Dim EndTime(3) as integer
Dim ElapsedTime(3) As integer
Dim i as integer
Dim ExecuteDate as String
Dim ExecuteTime as String
Dim d as New Date
Dim dumpvar(3) as string
Dim http as New TCPSocket1
// Start Code Here
ExecuteDate = d.ShortDate
ExecuteTime = d.ShortTime
MessagesFld.text = ""
http.yield=True
For i=0 to 2
StartTime(i)=0
EndTime(i)=0
ElapsedTime(i)=0
Next
For i=0 to 2
MessagesFld.text = MessagesFld.text + "Opening URL #" +str(i+1) + chr(13)
MessagesFld.text = MessagesFld.text + testURL(i) + chr(13)
StartTime(i)=TIcks
Call http.get (testURL(i),60)
EndTime(i)=Ticks
ElapsedTime(i)=EndTime(i)-StartTime(i)
MessagesFld.text = MessagesFld.text + "Time to Fetch =
"+str(ElapsedTime(i)/60)+" seconds" + chr(13)
Next
ResultsLst.addRow ExecuteDate
ResultsLst.cell(ResultsLst.lastIndex,1) = ExecuteTime
ResultsLst.cell(ResultsLst.lastIndex,2) = str(ElapsedTime(0)/60)
ResultsLst.cell(ResultsLst.lastIndex,3) = str(ElapsedTime(1)/60)
ResultsLst.cell(ResultsLst.lastIndex,4) = str(ElapsedTime(2)/60)
End Sub
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>
|