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
and this is when the data arrivesCode: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
this is the code to sendCode: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
so senddataa thefile, sends the name and extension, and threw what connection, but it only sends like up to 6mb n crashes any ideas?Code:senddataa txtFile, GetFileName(txtFile), Winsock1
EDIT: i get the error OUT OF STACK SPACE on DoEvents under Dim ifreefile




Reply With Quote