Hello all,

I am currently working on a internet/lan chat system which basically routes all commands through a central server to all other clients thus avoiding the problems with firewalls and what not. The chat part works perfectly and could not be better. However my file transfer is giving me some problems. All the commands and data are being transferred fine through the server from one client to another, however when it reaches the receive client it is only storing about 5% of the data received. Below are some functions I am using. Below is the receiver client functions:

Code:
Public FFile as double

Function GetFileUp1(who As String, filedata As String)
Dim rProc As String
Dim rProc2 As Integer
Dim rName As String
Dim msglen As String

Dim bytesTotal As Long
bytesTotal = bytesTotal + Len(filedata)

If frmmain.wsock.State <> sckConnected Then Exit Function


Transfered = Transfered + bytesTotal
pFull.Value = pFull.Value + bytesTotal
rProc = CInt(100 / pFull.Max * pFull.Value)
lblFull.Caption = rProc & "% completed."
lblSyn.Caption = "Stored " & KB(Int(pFull.Value)) & " of " & KB(Int(pFull.Max)) & "."

Put Val(FFile), , filedata
frmmain.SendDataF "999;" & who & vbLf & frmmain.myName & vbCrLf
End Function


Function TransFilez1(filesz As String, CRC4 As String, who As String)
Dim msglen As String
Dim bbj As String
Dim rPath As String, rFilePath  As String
Dim rCRC, rCRC2 As String
Dim rFileNameOnly As String
Dim iCount
Dim i As Integer
Dim iTemp, rTemp, rTempV, rTmp

CRC = CRC4
lblStatus.Caption = filesz

If Len(lblFiles) > 16 Then
msglen = Len(lblFiles) - 16
lblFiles.Caption = Val(Left(lblFiles.Caption, msglen)) - 1
Else
End If

lblFiles.Visible = True
bbj = lblFiles.Caption & " Files Remaining"
lblFiles.Caption = bbj
msglen = Len(lblFiles) - 16

If Val(Left(lblFiles.Caption, msglen)) = 1 Then
lblFiles.Caption = "1 File Remaining..."
End If

If Val(Left(lblFiles.Caption, msglen)) <= 0 Then lblFiles.Caption = "0 Files Remaining"
If filesz = "" Then
                   frmmain.SendDataF "error;invalid_filename" & vbCrLf
                   UnloadMe = True
                   MsgBox ("Error: Could Not Complete Request")
                   Unload Me
                   Exit Function
End If

rPath = FindSystemFolder(My_Documents)
If Mid(rPath, Len(rPath)) <> "\" Then
rPath = rPath & "\"
End If

rPath = rPath & "My Received Files\"
CreateDir rPath
rFilePath = rPath & filesz
Err = 0
rCRC = GetSetting("Action Pal Messenger", "ResumeFiles", lblStatus.Caption, "")

Err = 0
FFile = FreeFile
Open rFilePath For Binary Access Write As FFile

If Err = 0 Then
frmmain.SendDataF "transfer1;" & who & vbLf & frmmain.myName & vbCrLf
Else
Close FFile
End If

End Function
Next is the client's send function

Code:
Function SendFileUp(who As String)
Dim frm As Form
Dim fr
Dim FileCont As String
Dim rProc
Dim rName As String
Dim BytesSent As Long
For Each frm In Forms
If frm.Tag = "sendfile" & vbLf & who Then
frm.ProgressBar1.Min = 0
frm.ProgressBar1.Max = 100
fr = Val(frm.fr)
Err = 0
If Err <> 0 Then Exit Function
If wsock.State <> sckConnected Then Exit Function

Do
DoEvents
If LOF(fr) - frm.Transfered < frm.cur_FileBuf Then
                    FileCont = Input(LOF(fr) - frm.Transfered, fr)
                    frm.Transfered = frm.Transfered + (LOF(fr) - frm.Transfered)
                    DoEvents
                Else
                    FileCont = Input(frm.cur_FileBuf, fr)
                    frm.Transfered = frm.Transfered + frm.cur_FileBuf
                    DoEvents
End If
                SendDataF "020;" & who & vbLf & frmmain.myName & vbLf & FileCont & vbCrLf
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
BytesSent = BytesSent + Len(FileCont)
frm.SentSize = frm.SentSize + BytesSent

If frm.SentSize <> 0 Then
rProc = CInt(100 / LOF(fr) * frm.SentSize)
frm.ProgressBar1.Value = rProc
End If
frm.lblP.Caption = "Sending File " & rProc & "%"
frm.Caption = rProc & "% Completed."

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
frm.WaitForRemote
If frm.Transfered >= LOF(fr) Then Exit Function
Loop
End If
Next

End Function

Now like I said earlier the sending of all the file is fine coming from the client that sends it, however it is when the client is just about to put it into the receive file at exactly this point:

Put val(ffile),, filedata

that is in the receive function. It just gets stuck there and 100% it has nothing to do with the data received or sent because I have seen that it all goes through but gets stuck at that point. Any help would be great.

Thanks
HH