单片机采集数据通过TCP将数据发送到电脑,我在电脑用VB6的winsock编写一个TCP服务器。我怎么将数据取出来分类
单片机采集数据通过TCP将数据发送到电脑,我在电脑用VB6的winsock编写一个TCP服务器。我怎么将数据取出来分类。我现在不知道是不是先接收数据在显示。比如是从Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) '网络接收这里取出接收数据,在将数据分类显示呢。问题是我不知道怎么取出数据。On Error GoTo Err
If bytesTotal > 0 Then
If PacketCount >= MaxPacket Then PacketCount = 0
DisplaySerial = 1 + DisplaySerial
ConstStr1 = ">>> " + CStr(DisplaySerial) + ")" + CStr(Time) + " 接收到IP " + Winsock1.RemoteHostIP + " 端口 " + CStr(Winsock1.RemotePort) + " 数据"
If RecieveTypeChk.Value = 0 Then
Dim TempStr As String
Winsock1.GetData TempStr, vbString
StrData = StrData + ConstStr1 + "(" + CStr(Len(TempStr)) + "):" + vbCrLf + TempStr + vbCrLf
RecieveCount = RecieveCount + Len(TempStr)
Else
If ByteLenght = 0 Then
ReDim ByteData(bytesTotal)
Winsock1.GetData ByteData, vbByte, bytesTotal
ByteLenght = bytesTotal
Else
Dim TempByte() As Byte
ReDim TempByte(bytesTotal)
Winsock1.GetData TempByte, vbByte, bytesTotal
ReDim Preserve ByteData(ByteLenght + bytesTotal)
CopyMemory1 ByteData(ByteLenght), TempByte(0), bytesTotal
ByteLenght = ByteLenght + bytesTotal
End If
ConstStr1 = ConstStr1 + "(" + CStr(bytesTotal) + "):" + vbCrLf
StrHexHead = StrHexHead + ConstStr1
PacketHeadLenght(PacketCount) = Len(ConstStr1)
PacketTextLenght(PacketCount) = bytesTotal
PacketCount = PacketCount + 1
RecieveCount = RecieveCount + bytesTotal
End If
If ServerFlag = 2 And Winsock1.RemoteHostIP <> "" Then
Call CheckRecCombo(Winsock1.RemoteHostIP + ":" + CStr(Winsock1.RemotePort))
End If
DoEvents '空操作,返回cpu控制权
'Conststr2 = " 的端口 " + Winsock1.RemotePort + " 数据:>>>"
End If
Err:
Err.Clear
End Sub