Hey,
leider schon mein zweites Problem in zwei Tagen.
Es handelt sich um einen Filetransfer.
Wenn ich auf meinem Rechner das Programm zweimal starte und eine 4 MB Datei „versende“, dann dauert das ganze 30 Minuten.
Das Programm hängt aber nicht in irgendwelchen Schleifen, sondern bleibt bei der Ausführung über eine Sekunde bei „Winsock.SendData“ hängen. Ich habe absolut keine Ahnung, warum das so lange dauert.
Sind 1024 Byte als Block etwa zu groß?
Ich poste zum besseren Verständis mal den Code:
'Gilt für beide
Const Block = 1024
'Beim Sender
Private strFile As String
Private Sub sendfile()
Dim sData As String
Dim intDateiNr As Integer
intDateiNr = FreeFile
Open strFile For Binary Access Read As #intdateinr
Do While Not EOF(intdateinr)
sData = Input(Block, #intdateinr)
wsckFile.SendData sData
DoEvents
Loop
Close #intdateinr
End Sub
'Beim Empfänger
Private pos As Long
Private strFile As String
Private Sub wsckfile_DataArrival(ByVal bytesTotal As Long)
Dim BlocksCount As Integer
Dim intNewFile As Integer
Dim Data As String
BlocksCount = bytesTotal / Block
If pos = 0 Then
pos = 1
End If
wsckFile.GetData Data
intNewFile = FreeFile
For i = 1 To BlocksCount
Open strFile For Binary Access Write As #intNewFile
Seek #intNewFile, pos
Put #intNewFile, , Left(Data, Block)
Close #intNewFile
pos = pos + Block
If Len(Data) > Block then
Data = Mid(Data, Block + 1)
End if
Next i
End Sub
Vielen Dank im Vorraus.
MfG Hendrik Hilleckes