PDA

Click to See Complete Forum and Search --> : Sending large amount of data useing winsock, and it slows my application?


deoblo1
Dec 7th, 2000, 08:28 AM
This is my 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?

Cander
Dec 7th, 2000, 12:20 PM
add a DoEvents to your For loop