View Single Post
  #22 (permalink)  
Old 02-12-2010, 06:18 AM
Erel's Avatar
Erel Erel is online now
Administrator
 
Join Date: Apr 2007
Posts: 15,677
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

The stream is first saved to a file. Then you can open it with BinaryFile and read it to an array:
Code:
Sub Globals
    
Dim buffer(0As byte
End Sub

Sub App_Start
    Form1.Show
    request.New1(
"http://www.basic4ppc.com")
    response.New1
    request.GetAsyncResponse
End Sub

Sub request_Response
      
If request.ResponseCode = 200 Then '200 is the code of successful connections.
            response.Value = request.AsyncResponse
            response.GetAsyncStream(AppPath & 
"\tempfile"'Stream is saved to this file
      Else
            
Msgbox("Error getting response: " & request.ErrorMessage & CRLF _
            & 
"Response code: " & request.ResponseCode)
      
End If
End Sub

Sub response_Stream
    
'file is ready
    FileOpen(c, AppPath & "\tempfile", cRandom)
    binaryFile.New1(c, 
False)
    
Dim buffer(FileSize(AppPath & "\tempfile")) As byte
    
Msgbox(binaryFile.ReadBytes(buffer(), ArrayLen(buffer())))
    FileClose(c)
    
End Sub
Attached Files
File Type: sbp 1.sbp (310 Bytes, 12 views)
Reply With Quote