Private Sub sck_DataArrival(index As Integer, ByVal bytesTotal As Long)
'On Error Resume Next
Dim WskCommand As String
Dim CmdArr() As String
Dim FileByte() As Byte
If OnSendServer(index) = 1 Then '如果是在接收"字节"数据状态时
sck(index).GetData FileByte, vbArray + vbByte '接收类型为:字节数组
Put #GetFileNum(index), , FileByte '----------标线:)-------------
LenFile(index) = LenFile(index) - (UBound(FileByte) + 1) '数组的第一维是0.所以这里+1
'AddSevLog "剩余长度: " & LenFile(index) & " ..."
If LenFile(index) <= 0 Then
Close #GetFileNum(index)
OnSendServer(index) = 0
SckSendData index, "文件接收结束代替字符"
End If
Exit Sub
End If此为文件接收时的代码,在大部分情况下进行文件接收都没有问题。
但偶尔会出现接收的数据重复写入文件。现在怀疑是接收重复导致的还是写数据重复导致的?tcp连接应该是很稳定的。不知道有没有哪位朋友在写这个传输有好的解决办法!
'On Error Resume Next
Dim WskCommand As String
Dim CmdArr() As String
Dim FileByte() As Byte
If OnSendServer(index) = 1 Then '如果是在接收"字节"数据状态时
sck(index).GetData FileByte, vbArray + vbByte '接收类型为:字节数组
Put #GetFileNum(index), , FileByte '----------标线:)-------------
LenFile(index) = LenFile(index) - (UBound(FileByte) + 1) '数组的第一维是0.所以这里+1
'AddSevLog "剩余长度: " & LenFile(index) & " ..."
If LenFile(index) <= 0 Then
Close #GetFileNum(index)
OnSendServer(index) = 0
SckSendData index, "文件接收结束代替字符"
End If
Exit Sub
End If此为文件接收时的代码,在大部分情况下进行文件接收都没有问题。
但偶尔会出现接收的数据重复写入文件。现在怀疑是接收重复导致的还是写数据重复导致的?tcp连接应该是很稳定的。不知道有没有哪位朋友在写这个传输有好的解决办法!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货