Jump to content
Sign in to follow this  

A working timeout on InetRead or _INetGetSource?

Recommended Posts

Pretty simple.  

I need a setting or a loop to kick out of one of these commands if they do not return the data on 2,4,7  seconds.

#include <IE.au3>
#include <Inet.au3>
;Pretty simple.
Local $UnitName = BinaryToString(InetRead('https://www.autoitscript.com/site/autoit/' 1))
If @error <> 0 Then
ConsoleWrite("_INetRead did not return.  " & @CRLF)
;~ or
;~ Local $UnitName = (_INetGetSource('https://www.autoitscript.com/site/autoit/' 1))
;~ If @error <> 0 Then
;~ ConsoleWrite("_INetGetSource did not return.  " & @CRLF)
;~ EndIf
ConsoleWrite("_INetGetSource " & $UnitName & @CRLF)
Thanks in advance


Share this post

Link to post
Share on other sites

A way to call multiple InetRead or _INetGetSource simultaneously would be super helpful as well.

I am actually pulling data from multiple similar devices on a single subnet. The devices usually respond to their http: requests almost instantly. When they don't, that http: data can take 10 to 30 seconds. I've found if I just hit them with the same command a second after I don't get a response about 80% of the tme, the units respond instantly. 

If I could send a InetRead or _INetGetSource, wait 1 second for response then send another immediately if not response is received thsi would minutes off a process that should take seconds.

Edited by MrPinkComputerShrink

Share this post

Link to post
Share on other sites

Got it...    :sorcerer:    from another post about this same thing.  Newbie I am.

func _inetread_timeout($URL, $HTLM)
    ;msgbox (0, "$URL   $IP" , $URL & " " & $IP)

    dim $Timer,$PID,$initread_server,$chars,$timer_result,$timeout_server=1 ;second
    $Timer = TimerInit()
    $PID = Run(@AutoItexe & ' /AutoIt3ExecuteLine "filewrite(@tempdir&''\initread.txt'',inetread('''  & $URL & ''',1))"',"",@SW_HIDE)
    While 1
        If $pid=0 or TimerDiff($Timer)/1000 >= $timeout_server Then
            msgbox(48,"Error","timeout = "&$timer_result)
        ElseIf FileExists(@tempdir&"\initread.txt") and not ProcessExists($PID) then
            ;consolewrite ("timeout = " & $timer_result & @CRLF & $chars & @CRLF)
            $HTML = $chars
           ; msgbox(64,"timeout = "&$timer_result,$chars)
    Return $HTML

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...