Results 1 to 14 of 14

Thread: need more help with resume

  1. #1

    Thread Starter
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    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:
    1. dim lengthfile as double
    2. lengthfile = FileLen(.FileName)
    3. Open .FileName For Binary As #1
    4. xTransfer = True
    5.             winsock1.SendData "|RESUME|" & lvFiles.SelectedItem.Key & lengthfile

    server side recieves this,

    VB Code:
    1. Private Sub winsock1_DataArrival(ByVal bytesTotal As Long)
    2.  Dim recievedataAs String
    3. winsock1.GetData recievedata
    4.  
    5. resumesendFile ?????? ,winsock1
    6.  
    7. End sub


    VB Code:
    1. Public Sub ResumeSendFile(FileName As String, WinS As Winsock)
    2.  
    3. Dim FreeF As Integer
    4. Dim LenFile As Long
    5. Dim nCnt As Long
    6. Dim LocData As String
    7. Dim LoopTimes As Long
    8. Dim i As Long
    9.  
    10. FreeF = FreeFile
    11.  
    12. Open FileName For Binary As #99
    13.  
    14. nCnt = 1
    15.  
    16. LenFile = LOF(99)
    17.  
    18. WinS.SendData "|FILESIZE|" & LenFile
    19. DoEvents
    20.  
    21. Sleep (400)
    22.  
    23.  
    24. Do Until nCnt >= (LenFile)
    25.  
    26.     LocData = Space$(1024)
    27.  
    28.  
    29.   Get #99, nCnt, LocData
    30.  
    31.  
    32.   If nCnt + 1024 > LenFile Then
    33.       WinS.SendData Mid$(LocData, 1, (LenFile - nCnt))
    34.   Else
    35.  
    36.     WinS.SendData LocData
    37.   End If
    38.  
    39.   nCnt = nCnt + 1024
    40.  
    41. Loop
    42.  
    43. Close #99
    44.  
    45. 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 ?

  2. #2

    Thread Starter
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959
    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

  3. #3
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    Add proper splits in

    [Resume], Filename, Start Point


    VB Code:
    1. Dim strData() as string
    2.  
    3.    'Splits into strings using the "," as a cut point
    4.    strData = split(WinsockReturnedData, ",")
    5.  
    6.    'Get the right string and retrieve the requested files length
    7.    FileLength = Filelen(strData(1))
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  4. #4
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703
    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.
    an ending

  5. #5
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    With TCP IP you should be ok
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  6. #6
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703
    What do you mean by ok?
    an ending

  7. #7
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    Data recieved comes in the order and size that you sent it in.

    Make sure you have SP5 for VB though or winsock will be buggy
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  8. #8
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703
    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.
    an ending

  9. #9
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    I have never had trouble before
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  10. #10
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703
    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?
    an ending

  11. #11
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    The receieved data
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  12. #12
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703
    an ending

  13. #13
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176


    Sorry that was just itching to come out
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  14. #14
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703
    i rather suspected so
    an ending

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