|
-
Mar 31st, 2004, 03:42 AM
#1
Thread Starter
Frenzied Member
need more help with resume
Ok i want to resume a file from a client server setup and this is what i have so far,
client side gets file length of local file that is partially downloaded already and sends this info to server,
VB Code:
dim lengthfile as double
lengthfile = FileLen(.FileName)
Open .FileName For Binary As #1
xTransfer = True
winsock1.SendData "|RESUME|" & lvFiles.SelectedItem.Key & lengthfile
server side recieves this,
VB Code:
Private Sub winsock1_DataArrival(ByVal bytesTotal As Long)
Dim recievedataAs String
winsock1.GetData recievedata
resumesendFile ?????? ,winsock1
End sub
VB Code:
Public Sub ResumeSendFile(FileName As String, WinS As Winsock)
Dim FreeF As Integer
Dim LenFile As Long
Dim nCnt As Long
Dim LocData As String
Dim LoopTimes As Long
Dim i As Long
FreeF = FreeFile
Open FileName For Binary As #99
nCnt = 1
LenFile = LOF(99)
WinS.SendData "|FILESIZE|" & LenFile
DoEvents
Sleep (400)
Do Until nCnt >= (LenFile)
LocData = Space$(1024)
Get #99, nCnt, LocData
If nCnt + 1024 > LenFile Then
WinS.SendData Mid$(LocData, 1, (LenFile - nCnt))
Else
WinS.SendData LocData
End If
nCnt = nCnt + 1024
Loop
Close #99
End Sub
so according to this i think i have to make nct the value of the client side filelength. Could be way off but thats the way it looks to me.
any suggestions ?
-
Mar 31st, 2004, 04:13 AM
#2
Thread Starter
Frenzied Member
Ok i added a delimiter "," so all i really have to do is parse this typical line to get the file length, any help on parsing this line would be great.
|resume|c:\program files\file1.exe,235043
-
Apr 1st, 2004, 08:01 AM
#3
KING BODWAD XXI
Add proper splits in
[Resume], Filename, Start Point
VB Code:
Dim strData() as string
'Splits into strings using the "," as a cut point
strData = split(WinsockReturnedData, ",")
'Get the right string and retrieve the requested files length
FileLength = Filelen(strData(1))
-
Apr 1st, 2004, 08:15 AM
#4
Fanatic Member
You aren't guaranteed to receive a complete "request" from the client with one GetData call; your server code is assuming that you do.
You must check you have a complete request before using it. Also remember that you could feasibly receive more than a complete request from a GetData call; you need to account for this possibility aswell.
-
Apr 1st, 2004, 08:49 AM
#5
KING BODWAD XXI
With TCP IP you should be ok
-
Apr 1st, 2004, 10:04 AM
#6
Fanatic Member
-
Apr 1st, 2004, 10:23 AM
#7
-
Apr 1st, 2004, 10:32 AM
#8
Fanatic Member
Uh, yes you receive the data that was sent in the correct order, but there are no guarantees about how much data a particular GetData call will return. Winsock doesn't know what you consider to be a "request" or "command" at the application level.
-
Apr 2nd, 2004, 02:20 AM
#9
KING BODWAD XXI
I have never had trouble before
-
Apr 2nd, 2004, 02:31 AM
#10
Fanatic Member
Argh! That doesn't mean it's correct, I've seen apps break because of this when "out in the wild"!
To clarify before I go on more: what is your assumption on what a GetData call will return?
-
Apr 2nd, 2004, 02:39 AM
#11
-
Apr 2nd, 2004, 02:42 AM
#12
Fanatic Member
-
Apr 2nd, 2004, 02:44 AM
#13
-
Apr 2nd, 2004, 02:46 AM
#14
Fanatic Member
i rather suspected so
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|