|
-
Sep 2nd, 2001, 01:46 PM
#1
Thread Starter
Fanatic Member
need help doing Multiple Simultaneouis FILE TRANSFERS Usin Winsock. PLEEEEEEEESE Help
Heres the code i currently use. but when i try to send two files one stops going until the other finishes. Is there a way I can stop this?
Option Explicit
'You don't use this API function.
'Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'Dim lcounter As Long
'Do this...
Private lcounter As Long
'Pass strFilename 'ByVal'
Public Sub SendFile(ByVal strFileName As String, wins1 As winsock)
'Use proper coding conventions. Use prefixes such as int, byt etc.
'Use descriptive variable names.
'Dim FreeF2 As Integer
Dim intFreeFile As Integer
'Dim LocData2() As Byte
Dim bytTwoKB() As Byte
'Dim LenData2 As Long
Dim lngLen As Long
'Dim sendloop2 As Long
Dim lngCount As Long
intFreeFile = FreeFile 'Get free file.
Open strFileName For Binary As #intFreeFile 'Open file
ReDim bytTwoKB(1 To 2048) As Byte 'Work in 2kb chunks
lngLen = LOF(intFreeFile) 'Get length of file
For lngCount = 1 To lngLen \ 2048 'Go through file
Get #intFreeFile, , bytTwoKB 'Get data from the file nCnt is from where to start the get
DoEvents 'Give some time.
wins1.SendData bytTwoKB 'Send the chunk
DoEvents 'Give some time.
lcounter = lcounter + 1
'Form a proper 'If Else' case.
'If lCounter Mod 50 = 0 Then DoEvents
If lcounter Mod 50 = 0 Then
DoEvents
End If
'Always clarify the variable in a loop. 'Next' wont work if you have loops within loops...
'Next
Next lngCount
If lngLen Mod 2048 <> 0 Then ' If there is any left over at the end
ReDim bytTwoKB(1 To lngLen Mod 2048) As Byte 'Resize byte array.
Get #intFreeFile, , bytTwoKB 'Get the chunk.
DoEvents 'Give some time.
wins1.SendData bytTwoKB 'Send the chunk
DoEvents 'Give some time.
End If
Close #intFreeFile
DoEvents
End Sub
'Use descriptive sub/function names...
'ByRef is fine, as we may be dealing with large amounts of data.
Public Function oPD(strData As String) As String
MsgBox "used oPD"
'Again, use descriptive variable names.
'Dim TextC As String * 3
Dim strFix3 As String * 3 'Fixed length string. 3 characters.
Dim G As Long
Dim lngLen As Long 'Length of data
'Dim TextX As String
Dim strOut As String 'Output string.
'Dim x As Long
Dim i As Long 'Counting variable.
lngLen = Len(strData)
'Generally, use letters i, j, k for counting variables... coders tradition.
For i = 1 To lngLen
strFix3 = Asc(Mid(strData, i, 1))
strOut = strOut & strFix3
Next i
oPD = strOut
End Function
'Use descriptive sub/function names...
Public Function rPD(Text As String) As String
MsgBox "used rPD"
'Again, use descriptive variable names.
'Dim TextC As String * 3
Dim strFix3 As String * 3 'Fixed length string. 3 characters.
Dim G As Long
Dim lngLen As Long 'Length of data
'Dim TextX As String
Dim strOut As String
'Dim x As Long
Dim i As Long 'Counting variable
lngLen = Len(Text)
For i = 1 To G
'The Chr() function takes a long. Convert the expression using Clng.
'First check if it is numeric.
If IsNumeric(Trim(Mid(Text, i, 3))) = True Then
strFix3 = Chr(CLng(Mid(Text, i, 3)))
End If
strOut = strOut & strFix3
Next i
rPD = strOut
End Function
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
|