Hey, ich hab mir mal die Mühe gemacht und dein Skript ein wenig umgeschrieben sodass es effizienter und einfacher zu handhaben ist. Die Variablen hab ich jetzt ein wenig umbenannt weil ich's so besser lesen konnte xD
Kannst sie ja auch wieder selber umbenennen. Sind ja nicht so viele...
Spoiler anzeigen
; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +
[/autoit] [autoit][/autoit] [autoit]#include <GUIConstants.au3>
Global $hGUI, $idState, $bState, $sMessage
Global $iAcceptSocket = -1
TCPStartup()
Global Const $iMainSocket = TCPListen('127.0.0.01', 4321)
; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$hGUI = GUICreate('Server', 437, 467)
$idState = GUICtrlCreateButton('OFFLINE', 24, 405, 385, 33)
GUICtrlSetColor($idState, 0xFF0000)
GUICtrlCreateEdit('', 24, 16, 385, 377)
GUISetState()
; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]While True
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
TCPCloseSocket($iAcceptSocket)
TCPCloseSocket($iMainSocket)
TCPShutdown()
Exit
Case $idState
$bState = Not $bState
If $bState Then
GUICtrlSetData($idState, 'ONLINE')
GUICtrlSetColor($idState, 0x009900)
Else
GUICtrlSetData($idState, 'OFFLINE')
GUICtrlSetColor($idState, 0xFF0000)
EndIf
EndSwitch
If $iAcceptSocket = -1 Then $iAcceptSocket = TCPAccept($iMainSocket)
$sMessage = TCPRecv($iAcceptSocket, 2048)
If $bState And $sMessage Then MsgBox(64, 'Message', $sMessage)
WEnd
; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +
[/autoit]