vb6编写telnet后台老板工具,返回数据不正常

vb6编写telnet后台工具,返回数据不正常!
本帖最后由 adwnjt 于 2014-09-10 13:58:35 编辑
从网上找了段代码,修改了一翻也能正常登陆,但是在返回数据的时候,如果是命令的话,总是分开返回的。为什么会这样
比如我输入命令"dis clock",该命令文本会被分数次返回(视命令长度),
有时会是"d","is clock",有时可能会是"dis"," clock"
请高手帮我看看是为什么
如果能用白话解释一下telnet那些255,254,251,252等等代码更加感谢,网上找的资料实在看不明白如何使用。
代码如下:

Dim Receiving As Boolean

Private Sub Command1_Click()
If Winsock1.State <> 7 Then Exit Sub
s_str = Trim(Text1.Text) & Chr(13)
Winsock1.SendData s_str
Text1.Text = ""
End Sub

Private Sub Form_Load()
If Winsock1.State <> 0 Then Exit Sub
Winsock1.RemotePort = "23"
Winsock1.RemoteHost = "192.168.4.1"
Winsock1.Connect
Me.Caption = "Connecting"
End Sub

Private Sub Form_Resize()
List1.Left = Form1.ScaleLeft + 240
List1.Width = Form1.ScaleWidth - 440
List1.Top = 960
List1.Height = Form1.ScaleHeight - 1100
End Sub

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 Not Receiving Then
        Receiving = True
    Else
        ReList "busy"
        Receiving = False
        Exit Sub
    End If
    '判断是否有返回数据
    If (bytesTotal > 0) Then
        Winsock1.GetData ch, vbByte + vbArray, bytesTotal
    Else
        Receiving = False
        Exit Sub
    End If
    For i = 0 To bytesTotal - 1
        str = str & Chr(ch(i))
    Next i
    
    If Not_Echo = False Then
        If ch(0) <> 255 Then
            For i = 0 To bytesTotal - 1
                If ch(i) = 13 Then
                    ReList Str_Tmp
                    Str_Tmp = ""
                Else
                    '把换行符过滤掉
                    If ch(i) = 10 Then
                        Str_Tmp = ""
                    Else
                        If Not_Return = True Then
                            If List1.ListCount > 0 Then
                                Str_Tmp = List1.List(List1.ListCount - 1) & Chr(ch(i))
                                List1.RemoveItem List1.ListCount - 1
                            End If
                            Not_Return = False
                        Else