VB Code:
  1. Private Sub sckDownload_DataArrival(ByVal bytesTotal As Long)
  2.     Dim Pos                             As Integer
  3.     Dim LENGTH                          As Integer
  4.     Dim HEAD                            As String
  5.     Debug.Print bytesTotal
  6.    
  7.     Dim m_sData() As Byte
  8.    
  9.      sckDownload.GetData m_sData(), vbByte
  10.      'sckDownload.GetData m_sDATA, vbString
  11.      
  12.      Debug.Print "receiving data"
  13.      
  14.      If InStr(LCase(m_sData), "content-type:") Then         If RESUMEFILE = True Then 'check to see if its gonna resume ok or not..This is actually the worst way to check this.
  15.              If InStr(LCase(m_sData), "206 partial content") = 0 Then
  16.                  MsgBox "Server did not accept resuming.", vbCritical, "No Resuming Support"
  17.                  Reset
  18.                  CloseSocket
  19.                  Exit Sub
  20.                  End If
  21.             End If
  22.      
  23.          If InStr(LCase(m_sData), "404 not found") > 0 Then
  24.              MsgBox "The file requested was not found on the server!" & vbCrLf & vbCrLf & "Possible Reasons:" & vbCrLf & "- File Does Not Exist On Server" _
  25.              & vbCrLf & "- URL Given Was Script And Data Returned Was Invalid" & vbCrLf & "- URL Entered Was Incorrect" & vbCrLf & "- Server Is Excessively Busy" _
  26.              & vbCrLf & vbCrLf & "You may reattempt to download.  If its still failure then most likely invalid url.", , "File Not Found"
  27.              Reset
  28.              CloseSocket
  29.              Exit Sub
  30.          End If
  31.    
  32.          Pos = InStr(m_sData, vbCrLf & vbCrLf) ' find out where the header and the data is split apart
  33.          LENGTH = Len(CStr(m_sData)) 'get the length of the data chunk
  34.          HEAD = Left(m_sData, Pos - 1) 'Get the header from the chunk of data and ignore the data content
  35.          m_sData = Right(m_sData, LENGTH - Pos - 3) 'Get the data from the first chunk that contains the header also
  36.          Header = Header & HEAD 'Append the header to header text box
  37.          
  38.          If RESUMEFILE = True Then
  39.              BytesAlreadySent = FileLength + 1
  40.              BytesRemaining = GETDATAHEAD(Header, "Content-Length:")
  41.              BytesRemaining = BytesRemaining + FileLength
  42.          Else
  43.              BytesRemaining = GETDATAHEAD(Header, "Content-Length:")
  44.          End If
  45.          
  46.          Debug.Print "length: " & BytesRemaining
  47.          Debug.Print Header
  48.      End If
  49.      '-----------BEGIN WRITE CHUNK TO FILE CODE--------
  50.      Debug.Print "appending to file"
  51.      Open FilePathName For Binary Access Write As #1 'opens file for output
  52.      Put #1, BytesAlreadySent, m_sData 'writes data to the end of file
  53.      BytesAlreadySent = Seek(1)
  54.      Close #1 'close file for now until next data chunk is available
  55.      '--------------------------------------------------
  56.      
  57.      If RESUMEFILE = False Then
  58.               transferrate = Format(Int(BytesAlreadySent / (Timer - BeginTransfer)) / 1000, "####.00")
  59.      Else
  60.                 transferrate = Format(Int((BytesAlreadySent - FileLength) / (Timer - BeginTransfer)) / 1000, "####.00")
  61.      End If
  62.      Debug.Print "transfer rate: " & transferrate
  63. End Sub
  64.  
  65.  
  66. Private Sub sckDownload_Connect()
  67. On Error Resume Next
  68.     Dim strCommand                      As String
  69.    
  70.     Debug.Print "connected"
  71.    
  72.     'Right(URL, Len(URL) - Len(strSvrURL) - 7)
  73.     strCommand = "GET " + URL + " HTTP/1.1" + vbCrLf
  74.     strCommand = strCommand + "Accept: video/mpeg , video/avi" + vbCrLf
  75.    
  76.     If RESUMEFILE = True Then
  77.         strCommand = strCommand + "Range: bytes=" & FileLength & "-" & vbCrLf
  78.     End If
  79.    
  80.     strCommand = strCommand + "User-Agent: Video Crawler" & vbCrLf
  81.     strCommand = strCommand + "Referer: " & strSvrURL & vbCrLf
  82.     strCommand = strCommand + "Host: " & strSvrURL & vbCrLf
  83.    
  84.     strCommand = strCommand + vbCrLf
  85.    
  86.     Debug.Print strCommand
  87.     sckDownload.SendData strCommand 'sends a header to the server instructing it what to do!
  88.     BeginTransfer = Timer 'start timer for transfer rate
  89. End Sub


RESUMEFILE = FALSE, always

it does the same thing then m_sData was a string

it receives 10-256 bytes, and no more