Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim ch() As Byte
Dim tr() As Byte
Dim i As Integer
Dim str As String
Dim Pos_Tmp As Integer
Dim Str_Tmp As String
'-------------------------------------------------------------
If (bytesTotal > 0) Then ' If there is any data...
Winsock1.GetData ch, vbByte + vbArray, bytesTotal
Else
Receiving = False
Exit Sub
End If
'-----------------
str = ""
For i = 0 To bytesTotal - 1
str = str & Chr$(ch(i))
Next i
'Text3 = Text3 & str 全部显示所有命令和返回字符
Text3 = str
'--------------处理接收数据---------
Dim cc, ccc As String
cc = Right(Trim(Text3.Text), 2)
ccc = Right(Trim(cc), 1)
If cc = "n:" Then
flgcount = flgcount + 1
Receiving = True
End If
If cc = "d:" Then
flgcount = flgcount + 1
Receiving = True
End If
If ccc = ">" Then
flgcount = flgcount + 1
Receiving = True
End If
If ccc = "#" Then
flgcount = flgcount + 1
Receiving = True
End If
'---------------------------------------------
If ch(0) = 255 Then
If ch(1) = 253 Then
ReDim tr(14) As Byte
tr(0) = 255: tr(1) = 252: tr(2) = 24
tr(3) = 255: tr(4) = 252: tr(5) = 32
tr(6) = 255: tr(7) = 252: tr(8) = 35
tr(9) = 255: tr(10) = 252: tr(11) = 39
tr(12) = 255: tr(13) = 252: tr(14) = 36
End If
If ch(1) = 251 Then
ReDim tr(17) As Byte
tr(0) = 255: tr(1) = 253: tr(2) = 3
tr(3) = 255: tr(4) = 251: tr(5) = 1
tr(6) = 255: tr(7) = 252: tr(8) = 34
tr(9) = 255: tr(10) = 254: tr(11) = 5
tr(12) = 255: tr(13) = 252: tr(14) = 31
tr(15) = 255: tr(16) = 252: tr(17) = 37
End If
Winsock1.SendData tr
Receiving = False
End If