Hallo,
ich habe ein kleines Problem mit dem Code.
Ich habe alles genau auf mein Projekt übertragen, allerdings empfängt derServer nur 1024 Bytes.
Weiß jemand warum?
Vielleicht sollte ich noch erwähnen, das ich das ganze per TCP machen will (nicht UDP)
Server-Code:
Private Sub Form_Load()
wSock.LocalPort = 1234
wSock.Listen
End Sub
Private Sub wSock_ConnectionRequest(ByVal requestID As Long)
If wSock.State <> sckConnected Then
wSock.Close
End If
wSock.Accept requestID
End Sub
Private Sub wSock_DataArrival(ByVal bytesTotal As Long)
Static sFile As String
Dim sData As String, sTemp As String
wSock.GetData sData, vbString
'Neue Datei wird gesendet
If Left$(sData, 12) = "<begin size=" Then
sData = Mid$(sData, 13)
sTemp = Left$(sData, InStr(sData, ">") - 1)
sData = Mid$(sData, InStr(sData, ">") + 1)
If InStr(sTemp, ";") > 0 Then
nBytesTotal = Val(Left$(sTemp, InStr(sTemp, ";") - 1))
sFile = Mid$(sTemp, InStr(sTemp, ";") + 1)
Else
nBytesTotal = Val(sTemp)
End If
If Len(sFile) = 0 Then sFile = "temp.dat"
On Error Resume Next
Kill App.Path & "\" & sFile
On Error GoTo 0
nFile = FreeFile
Open App.Path & "\" & sFile For Binary As #nFile
nBytesRead = 0
End If
If Len(sData) > 0 And nFile > 0 Then
nBytesRead = nBytesRead + Len(sData)
Put #nFile, , sData
lblProgress.Caption = CStr(nBytesRead) & " of " & CStr(nBytesTotal) & "" & _
"bytes received"
If nBytesRead = nBytesTotal Then
Close #nFile
nFile = 0
End If
End If
End Sub
Private Sub wSock_Error(ByVal Number As Integer, Description As String, ByVal _
Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal _
HelpContext As Long, CancelDisplay As Boolean)
MsgBox ("Err: " & Number & vbCrLf & Description)
End Sub
Beitrag wurde zuletzt am 21.03.11 um 18:18:57 editiert. |