Array-Var Fehler

  • Hallo

    Ich habe mal wieder ein Fehler ich habe einen Server Programmiert mit den man per Client befehle senden kann ein befehl

    heißt /start mit diesen kann man auf den Pc wo der Server ist eine *.exe starten das klappt auch aber wenn ich mit den Client ein leeres Packet senden kommt ein Array fehler ich habe schon versucht es zu prüfen aber der Fehler bleibt vlt kann mir jemand helfen

    hier das script

    [autoit]

    #RequireAdmin
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Change2CUI=y
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include <Date.au3>

    [/autoit][autoit][/autoit][autoit]

    ; Die Pfad - Information
    Global $FilePfad = "Pfad.ini"
    Global $Pfad = IniRead($FilePfad, "Programm-Pfad", "Pfad", "")

    [/autoit][autoit][/autoit][autoit]

    ; Die Server - Information

    [/autoit][autoit][/autoit][autoit]

    Global $FileConnect = "ConnectInfo.ini"
    Global $IP = IniRead($FileConnect, "Connect", "IP", "")
    Global $PORT = IniRead($FileConnect, "Connect", "PORT", "")

    [/autoit][autoit][/autoit][autoit]

    ; Allgemeine - Information

    [/autoit][autoit][/autoit][autoit]

    Global $FileLog = "Server_log.txt"
    Global $BackAddress
    Global $Socket, $ConnectSocket = -1, $Revc, $RevcLen

    [/autoit][autoit][/autoit][autoit]

    ; Startausgaben

    [/autoit][autoit][/autoit][autoit]

    _Logwrite("Pfad : " & $Pfad, 3)
    _LogWrite("LISTEN IP : " & $IP & " PORT : " & $PORT, 3)

    [/autoit][autoit][/autoit][autoit]

    TCPStartup()
    $Socket = TCPListen($IP, $PORT)

    [/autoit][autoit][/autoit][autoit]

    Do
    $ConnectSocket = TCPAccept($Socket)
    Until $ConnectSocket <> -1

    [/autoit][autoit][/autoit][autoit]

    While 1
    $BackAddress = SocketToIP($ConnectSocket)
    $Revc = TCPRecv($ConnectSocket, 5000)
    $RevcLen = StringLen($Revc)
    If $RevcLen > 1 Then
    BefehlePruefen($Revc)
    EndIf
    WEnd
    TCPCloseSocket($ConnectSocket)
    TCPShutdown()

    [/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit][autoit]

    Func BefehlePruefen($oBefehl)
    Local $sStringSplit
    Local $Para1, $Para2, $Para3

    [/autoit][autoit][/autoit][autoit]

    $sStringSplit = StringSplit($oBefehl, ";")
    $Para1 = StringLen($sStringSplit[1])
    $Para2 = StringLen($sStringSplit[2])
    $Para3 = StringLen($sStringSplit[3])

    [/autoit][autoit][/autoit][autoit]

    If $Para1 >= 1 AND $Para2 >= 1 AND $Para3 >= 1 Then
    If $sStringSplit[1] == "/start" Then
    Run($Pfad & $sStringSplit[2] & "\" & $sStringSplit[3])
    If ProcessExists($sStringSplit[3]) Then
    _LogWrite("Form :" & $BackAddress & " Program : " & $sStringSplit[3] & " Gestartet !", 2)
    ElseIf Not ProcessExists($sStringSplit[3]) Then
    _LogWrite("Form :" & $BackAddress & " Program : " & $sStringSplit[3] & " konnte nicht Gestartet werden !", 1)
    Else
    _LogWrite("Form :" & $BackAddress & " Program : " & $sStringSplit[3] & " Prüfen sie den Pfad des Programmes !", 3)
    EndIf
    EndIf
    EndIf

    [/autoit][autoit][/autoit][autoit]

    EndFunc

    [/autoit][autoit][/autoit][autoit]

    Func _Logwrite($oText, $oFlag) ; Schreibt in die Console und in die $Filelog
    Local $Time = _NowTime() ; Die Aktuelle - Zeit
    Local $Date = _NowDate() ; Das Aktuelle - Datum

    [/autoit][autoit][/autoit][autoit]

    Switch $oFlag
    Case 1 ;-> Error
    ConsoleWrite("[ERROR - " & $Time & "] " & $oText & @CRLF)
    FileWrite($FileLog,"[ERROR - Zeit : " & $Time & " Datum : " & $Date & "] " & $oText & @CRLF)
    Case 2 ;-> System
    ConsoleWrite("[SYSTEM - " & $Time & "] " & $oText & @CRLF)
    FileWrite($FileLog,"[SYSTEM - Zeit : " & $Time & " Datum : " & $Date & "] " & $oText & @CRLF)
    Case 3 ;-> Info
    ConsoleWrite("[INFO - " & $Time & "] " & $oText & @CRLF)
    FileWrite($FileLog,"[INFO - Zeit : " & $Time & " Datum : " & $Date & "] " & $oText & @CRLF)
    EndSwitch
    EndFunc

    [/autoit][autoit][/autoit][autoit]

    Func SocketToIP($SHOCKET)
    Local $sockaddr, $aRet

    [/autoit][autoit][/autoit][autoit]

    $sockaddr = DllStructCreate("short;ushort;uint;char[8]")

    [/autoit][autoit][/autoit][autoit]

    $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _
    "ptr", DllStructGetPtr($sockaddr), "int*", DllStructGetSize($sockaddr))
    If Not @error And $aRet[0] = 0 Then
    $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3))
    If Not @error Then $aRet = $aRet[0]
    Else
    $aRet = 0
    EndIf

    [/autoit][autoit][/autoit][autoit]

    $sockaddr = 0

    [/autoit][autoit][/autoit][autoit]

    Return $aRet
    EndFunc ;==>SocketToIP

    [/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit]
  • Hallo NetCode,

    mach einfach eine Fehlerbehandlung in deine func:

    Spoiler anzeigen
    [autoit]

    Func BefehlePruefen($oBefehl)
    Local $sStringSplit
    Local $Para1, $Para2, $Para3

    [/autoit] [autoit][/autoit] [autoit]

    $sStringSplit = StringSplit($oBefehl, ";")
    If Not @error Then
    $Para1 = StringLen($sStringSplit[1])
    if sStringSplit[0] > 1 Then $Para2 = StringLen($sStringSplit[2])
    if sStringSplit[0] > 1 Then $Para3 = StringLen($sStringSplit[3])
    EndIf
    If $Para1 >= 1 And $Para2 >= 1 And $Para3 >= 1 Then
    If $sStringSplit[1] == "/start" Then
    Run($Pfad & $sStringSplit[2] & "\" & $sStringSplit[3])
    If ProcessExists($sStringSplit[3]) Then
    _LogWrite("Form :" & $BackAddress & " Program : " & $sStringSplit[3] & " Gestartet !", 2)
    ElseIf Not ProcessExists($sStringSplit[3]) Then
    _LogWrite("Form :" & $BackAddress & " Program : " & $sStringSplit[3] & " konnte nicht Gestartet werden !", 1)
    Else
    _LogWrite("Form :" & $BackAddress & " Program : " & $sStringSplit[3] & " Prüfen sie den Pfad des Programmes !", 3)
    EndIf
    EndIf
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>BefehlePruefen

    [/autoit]

    mfg autoBert

  • Z38-41 Von:

    [autoit]

    $RevcLen = StringLen($Revc)
    If $RevcLen > 1 Then
    BefehlePruefen($Revc)
    EndIf

    [/autoit]

    Zu:

    [autoit]

    If StringInStr($Revc, ';', 0, 2) Then BefehlePruefen($Revc)

    [/autoit]