Opt("MustDeclareVars",1) Const $SRV_IP_ADDRESS = '127.0.0.1' Const $SRV_PORT = '8080' Dim $SRV_SOCKET = -1 Dim $SRV_ACTIVE = True HotKeySet("{ESC}","_EscKey_OnPress") Func _EscKey_OnPress() $SRV_ACTIVE = False EndFunc _Service_OnStart() Func _Service_OnStart() Dim $iSocket Dim $sRequest Dim $sResponse If Not TCPStartup() Then _AppendToLog("TCPStartup failed. Error " & @error) Exit EndIf OnAutoItExitRegister("_Service_OnStop") $SRV_SOCKET = TCPListen($SRV_IP_ADDRESS, $SRV_PORT) if @error Then _AppendToLog("TCPListen failed. Error " & @error) EndIf _AppendToLog("Service started") While $SRV_ACTIVE $iSocket = TCPAccept($SRV_SOCKET) if @error Then _AppendToLog("TCPAccept failed. Error " & @error) Exit EndIf if $iSocket <> -1 Then _AppendToLog("Accepted connection. Socket " & $iSocket) $sResponse = "HTTP/1.1 200 OK" & @CRLF & "Connection: close" & @CRLF & @CRLF & "OK" $sRequest = TCPRecv($iSocket, 4000) _AppendToLog("Request length:" & StringLen($sRequest)) _AppendToLog($sRequest) ;_AppendToLog($sResponse) TCPSend($iSocket,$sResponse) TCPCloseSocket($iSocket) EndIf Wend EndFunc Func _Service_OnStop() If Not TCPShutdown() Then _AppendToLog("TCPStartup failed. Error " & @error) EndIf _AppendToLog("Service stopped") EndFunc Func _Time() Return @HOUR & ":" & @MIN & ":" & @SEC EndFunc Func _AppendToLog($sText) ConsoleWrite(_Time() & ": " & $sText & @CRLF) EndFunc