Results 1 to 2 of 2

Thread: Sending large amount of data useing winsock, and it slows my application?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Location
    Texas
    Posts
    313
    This is my code:

    Code:
    Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    
    Public Function SendLIST(index As Integer)
    Dim FreeF As Integer
    Dim LocData() As Byte
    Dim LenData As Long
    Dim sendloop As Long
    
    FreeF = FreeFile
    
        Open "D:\PROGRAM\List.txt" For Binary As #FreeF
        
        ReDim LocData(1 To 2048) As Byte ' Work in 2kb chunks
    
    LenData = LOF(FreeF) ' Get length of file
    
    For sendloop = 1 To LenData \ 2048 ' Go through file
    
      Get #FreeF, , LocData 'Get data from the file nCnt is from where to start the get
    
      Form1.Winsock1(index).SendData LocData 'Send the chunk
    
    Next
    
    If LenData Mod 2048 <> 0 Then ' If there is any left over at the end
      
      ReDim LocData(1 To LenData Mod 2048) As Byte ' Clear up the leftovers
      
      Get #FreeF, , LocData 'Get data from the file nCnt is from where to start the get
    
      Form1.Winsock1(index).SendData LocData 'Send the chunk
      
    End If
    
    Close #FreeF ' Close the file
    
    Sleep 200 ' Let computer catch up
    End Function
    IS their anything i can put in my code
    so my program does not freez up for a few seconds
    so kinda give the cpu some time, but no slow down my program
    or my transfer?

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913

    re:

    add a DoEvents to your For loop

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