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>
; Die Pfad - Information
Global $FilePfad = "Pfad.ini"
Global $Pfad = IniRead($FilePfad, "Programm-Pfad", "Pfad", "")
; Die Server - Information
[/autoit][autoit][/autoit][autoit]Global $FileConnect = "ConnectInfo.ini"
Global $IP = IniRead($FileConnect, "Connect", "IP", "")
Global $PORT = IniRead($FileConnect, "Connect", "PORT", "")
; Allgemeine - Information
[/autoit][autoit][/autoit][autoit]Global $FileLog = "Server_log.txt"
Global $BackAddress
Global $Socket, $ConnectSocket = -1, $Revc, $RevcLen
; Startausgaben
[/autoit][autoit][/autoit][autoit]_Logwrite("Pfad : " & $Pfad, 3)
_LogWrite("LISTEN IP : " & $IP & " PORT : " & $PORT, 3)
TCPStartup()
$Socket = TCPListen($IP, $PORT)
Do
$ConnectSocket = TCPAccept($Socket)
Until $ConnectSocket <> -1
While 1
$BackAddress = SocketToIP($ConnectSocket)
$Revc = TCPRecv($ConnectSocket, 5000)
$RevcLen = StringLen($Revc)
If $RevcLen > 1 Then
BefehlePruefen($Revc)
EndIf
WEnd
TCPCloseSocket($ConnectSocket)
TCPShutdown()
Func BefehlePruefen($oBefehl)
Local $sStringSplit
Local $Para1, $Para2, $Para3
$sStringSplit = StringSplit($oBefehl, ";")
$Para1 = StringLen($sStringSplit[1])
$Para2 = StringLen($sStringSplit[2])
$Para3 = StringLen($sStringSplit[3])
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
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
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
Func SocketToIP($SHOCKET)
Local $sockaddr, $aRet
$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
$sockaddr = 0
[/autoit][autoit][/autoit][autoit]Return $aRet
EndFunc ;==>SocketToIP