Results 1 to 1 of 1

Thread: Winsock File-Transfer problems

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2009
    Posts
    7

    Smile Winsock File-Transfer problems

    Hello,

    I am sorry if I am asking stupid questions, but I searched the entire web but couldn't find out what was wrong about my VB6 code:

    It's purpose is to send a file to a client, but the file get's damaged every time

    Does anyone know what is wrong? Thank you very much!

    -There is a Winsock control on my form called SendFile
    -The var Ready becomes true when the SendData event is fired.

    Client Code:
    1. Open FileName For Binary As #Filenum
    2.             If pos = 0 Then
    3.                 Put #Filenum, 1, Buffer
    4.             Else
    5.                 Put #Filenum, pos, Buffer
    6.             End If
    7.             pos = pos + Len(Buffer)
    8.         Close #Filenum

    Server Code:
    1. in top:
    2. Private Const chunk = 8192
    3.  
    4. In event:
    5.                Open Filename For Binary As #FileNum    
    6.            
    7.             FileLen = 0
    8.             Do While Not EOF(FileNum)
    9.                                                
    10.                 If FileLen + chunk > LOF(FileNum) Then
    11.                     Dim Diff
    12.                     Diff = LOF(FileNum) - FileLen
    13.                     data = Input(Diff, #FileNum)
    14.                     FileLen = FileLen + Diff
    15.                 Else
    16.                     data = Input(chunk, #FileNum)
    17.                     FileLen = FileLen + chunk
    18.                 End If
    19.                
    20.                 Do Until Ready = True
    21.                     DoEvents
    22.                 Loop
    23.                 SendFile.SendData data
    24.                 DoEvents
    25.             Loop
    26.         Close #FileNum
    Last edited by TrueSoftware; Dec 13th, 2009 at 02:41 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