Results 1 to 8 of 8

Thread: Help My File Transfer Can Only Send Up To 5Mb

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    53

    Help My File Transfer Can Only Send Up To 5Mb

    No idea what i did wrong... i can only send up to 6mb or else my program just exits itself on the client or host side whoever is sending how can i get it to send large files without getting this error?

    I took the code and modified from an example here is to send the data
    Code:
    Public Sub senddataa(sFile As String, sSaveAs As String, tcpCtl As Winsock)
    On Error GoTo ErrHandler
        Dim sSend As String, sBuf As String
        Dim ifreefile As Integer
        Dim lRead As Long, lLen As Long, lThisRead As Long, lLastRead As Long
        
        ifreefile = FreeFile
        
        ' Open file for binary access:
        Open sFile For Binary Access Read As #ifreefile
        lLen = LOF(ifreefile)
        
        ' Loop through the file, loading it up in chunks of 64k:
        Do While lRead < lLen
            lThisRead = 65536
            If lThisRead + lRead > lLen Then
                lThisRead = lLen - lRead
            End If
            If Not lThisRead = lLastRead Then
                sBuf = Space$(lThisRead)
            End If
            Get #ifreefile, , sBuf
            lRead = lRead + lThisRead
            sSend = sSend & sBuf
        Loop
        lTotal = lLen
        Close ifreefile
        bSendingFile = True
        '// Send the file notification
        tcpCtl.senddata "FILE" & sSaveAs
        DoEvents
        '// Send the file
        tcpCtl.senddata sSend
        DoEvents
        '// Finished
        tcpCtl.senddata "FILEEND"
        bSendingFile = False
        Exit Sub
    ErrHandler:
        MsgBox "Err " & Err & " : " & Error
    End Sub
    and this is when the data arrives

    Code:
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
        Dim strData As String
        Dim ifreefile
        
        DoEvents
        Winsock1.getdata strData
        If Right$(strData, 7) = "FILEEND" Then
            bFileArriving = False
            lblProgress = "Saving File to " & App.Path & "\" & sFile
            sArriving = sArriving & Left$(strData, Len(strData) - 7)
            ifreefile = FreeFile
                Open sFile For Binary Access Write As #ifreefile
                Put #ifreefile, 1, sArriving
                Close #ifreefile
            lblProgress = "Complete"
        ElseIf Left$(strData, 4) = "FILE" Then
            bFileArriving = True
            sFile = Right$(strData, Len(strData) - 4)
        ElseIf bFileArriving Then
            lblProgress = "Receiving " & bytesTotal & " bytes for " & sFile & " from " & Winsock1.RemoteHostIP
            sArriving = sArriving & strData
        End If
    End Sub
    this is the code to send
    Code:
    senddataa txtFile, GetFileName(txtFile), Winsock1
    so senddataa thefile, sends the name and extension, and threw what connection, but it only sends like up to 6mb n crashes any ideas?

    EDIT: i get the error OUT OF STACK SPACE on DoEvents under Dim ifreefile
    Last edited by Evilribbet; Jan 7th, 2009 at 10:49 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width