windows:autoit:wait_for_connection
This is an old revision of the document!
Some Windows machine needed to start Firefox only when the internal webserver is reachable after boot (the netcard was slow to start or something, I don't remember), so I made a quick script. The script tries to connect, waits, retries, retries… until it gets a response. Then it starts Firefox.
; Check HTTP answer $CheckHost = "jizzdk" $CheckPort = 80 $ConnectedOrNot = 0 ; Loop-de-loop! While $ConnectedOrNot = 0 TCPStartUp() Dim $ConnectedSocket = -1 $ConnectedSocket = TCPConnect(TCPNameToIP($CheckHost), $CheckPort) Dim $szData If @error Then $ConnectedOrNot = 0 Else TCPSend($ConnectedSocket, "GET / HTTP/1.0" & @CRLF & @CRLF) sleep(1500) $szData = TCPRecv($ConnectedSocket, 1024) If StringInStr($szData, "HTTP/1.1 200 OK") = 1 Then $ConnectedOrNot = 1 Run("C:\Program Files\Mozilla Firefox\firefox.exe") EndIf EndIf ; Close the connection again TCPCloseSocket($ConnectedSocket) TCPShutdown() WEnd
windows/autoit/wait_for_connection.1359629479.txt.gz · Last modified: 2015/08/15 22:56 (external edit)