#include Dim Const $host = "localhost" Dim Const $wait = 5 * 60 * 1000 Dim Const $log = @ScriptDir & "\uptime.log" Dim $laststatus = False While 1 $status = CheckAlive($host) If $status <> $laststatus Then $laststatus=$status $message = _Now() & " " & $host & " " If $status Then $message &= "online" Else $message &= "offline" EndIf TrayTip("Check alive", $message, 10) FileWriteLine($log, $message) EndIf Sleep($wait) WEnd Exit Func CheckAlive($host, $method = "ping", $port = False, $query = "HEAD / HTTP/1.0") Switch $method Case "ping" $ping=Ping($host) If $ping Then SetExtended($ping) Return True Else Return False EndIf Case "web" If Not $port Then $port = 80 Case "ftp" If Not $port Then $port = 21 Case Else Return False EndSwitch TCPStartup() $socket = TCPConnect(TCPNameToIP($host), $port) If $socket = -1 Then Return False TCPSend($socket, $query & @CRLF & "Host: " & $host & @CRLF & @CRLF) $response = False While Not $response $response = TCPRecv($socket, 1024) WEnd TCPCloseSocket($socket) TCPShutdown() $response = StringRegExp($response, "\d{3}", 1) If @error Then Return False $response=$response[0] $code = StringLeft($response, 1) SetExtended($response) If $code > 0 And $code < 4 Then Return True Return False EndFunc ;==>CheckAlive