Sign in to follow this  
Followers 0
daslick

Client/Server Recieve Loop

3 posts in this topic

This is the loop in my client...

It recieves data and uses a stringsplit on; characters (which are sent at the end of all lines in the server)
While 1
    $recieve = TCPRecv($socket, 10000)
    $incoming = StringSplit($recieve,";") 
    For $i = 2 to _ArrayMaxIndex($incoming, 1, 1) step 1
        if StringLeft($incoming[$i],5) = "data:" then $incoming[$i] = StringTrimLeft($incoming[$i], 5)
            Select
                Case 1 = 1
                    MsgBox(0,"",$incoming[$i])
                Case StringStripWS($incoming[$i],4) = ""
                Case IsNumber($incoming[$i])
                Case StringLeft($incoming[$i], 5) = "@ret@"
                    GUICtrlSetData($lab_stat, StringTrimLeft($incoming[$i], 5))
                Case StringLeft($incoming[$i],2) = "+\"
                    GUICtrlSetState($but_hide,@SW_ENABLE)
                    GUICtrlSetData($but_hide,"Show")
                    GUICtrlSetData($lab_stat, StringTrimLeft($incoming[$i][$i], 2))
                Case StringLeft($incoming[$i],2) = "-\"
                    GUICtrlSetState($but_hide,@SW_ENABLE)
                    GUICtrlSetData($but_hide,"Hide")
                    GUICtrlSetData($lab_stat, StringTrimLeft($incoming[$i][$i], 2))
                Case StringLeft($incoming[$i], 7) = "data:"
                    $incoming[$i] = StringTrimLeft($incoming[$i], 6)
                Case StringLeft($incoming[$i],6) = "!WIND!"
                    $incoming[$i] = StringTrimRight(StringTrimLeft($incoming[$i],6),1)
                    GUICtrlSetData($in_winspy, $incoming[$i])
                Case StringLeft($incoming[$i],6) = "!site!"
                    if $incoming[$i] = '!site!0;' then $incoming[$i] = '!site!;'
                    $incoming[$i] = StringTrimRight(StringTrimLeft($incoming[$i],6),1)
                    GUICtrlSetData($in_iespy, $incoming[$i])
                Case StringLeft($incoming[$i], 7) = "proces:"
                    GUICtrlSetData($process, "Server:" & @CRLF & StringTrimLeft($incoming[$i],7))
                Case StringLeft($incoming[$i], 7) = "windir:"
                    GUICtrlSetData($windir, 'Windows Directory:"' & StringTrimLeft($incoming[$i],7) & '"')
                Case StringLeft($incoming[$i], 7) = "sysdir:"
                    GUICtrlSetData($sysdir, 'System Directory:"' & StringTrimLeft($incoming[$i],7) & '"')
                Case StringLeft($incoming[$i], 7) = "WINDOS:"
                    GUICtrlSetData($OS, "Operating System:" & StringTrimLeft($incoming[$i], 7))
                Case StringLeft($incoming[$i], 7) = "CPNAME:"
                    GUICtrlSetData($CPname, "Computer/User:" & StringTrimLeft($incoming[$i], 7))
                Case StringLeft($incoming[$i], 7) = "CPDATE:"
                    GUICtrlSetData($date, "Date:" & StringTrimLeft($incoming[$i], 7))
                Case StringLeft($incoming[$i], 7) = "dEsKtP:"
                    GUICtrlSetData($desktop, 'Desktop:"' & StringTrimLeft($incoming[$i], 7) & '"')
                    $file1data[2] = StringTrimLeft($incoming[$i], 7)
                    $file2data[2] = StringTrimLeft($incoming[$i], 7)
                Case StringLeft($incoming[$i], 7) = "resoln:"
                    GUICtrlSetData($resolution, 'Monitor Resolution:' & StringTrimLeft($incoming[$i], 7))
                Case StringLeft($incoming[$i], 7) = "memory:"
                    GUICtrlSetData($memory, 'Total Physical RAM: ' & Ceiling(StringTrimLeft($incoming[$i], 7) / 1024) & " Mb")
                Case StringLeft($incoming[$i], 7) = "HDSIZE:"
                    GUICtrlSetData($drive, "Hard Drive Capacity: " & StringTrimLeft($incoming[$i], 7))
                Case StringLeft($incoming[$i], 7) = "HDFREE:"
                    GUICtrlSetData($drivefree, "Hard Drive Free Space: " & StringTrimLeft($incoming[$i], 7))
                Case StringLeft($incoming[$i], 8) = "tempdir:"
                    $file1data[1] = StringTrimLeft($incoming[$i], 8) & "\*"
                Case StringLeft($incoming[$i],6) = "!site!"
                    MsgBox(0,'',StringTrimLeft(StringTrimRight($incoming[$i],1),6))
                Case Else
                    MsgBox(0,"",$incoming[$i])
            EndSelect
        Next
WEnd

I am still working on the code... I don't understand why it doesn't work... It uses almost the same code as the server does to accept commands.

Could someone glance over it and offer suggestions?

Share this post


Link to post
Share on other sites

That line is intended to catch the $array's[0] that contains the index that arraysplit returns

--- I don't think that line is the problem... but I have tried it without that line and it does not help

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0