Sign in to follow this  
Followers 0
MrPinkComputerShrink

A working timeout on InetRead or _INetGetSource?

4 posts in this topic

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)
EndIf
 
;~ 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
 

inetgetpoo.au3

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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
    filedelete(@tempdir&"\initread.txt")
    $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
            $timer_result=TimerDiff($Timer)
            ProcessClose($PID)
            msgbox(48,"Error","timeout = "&$timer_result)
        ElseIf FileExists(@tempdir&"\initread.txt") and not ProcessExists($PID) then
            $timer_result=TimerDiff($Timer)
            $chars=fileread(@tempdir&"\initread.txt")
            filedelete(@tempdir&"\initread.txt")
            ;consolewrite ("timeout = " & $timer_result & @CRLF & $chars & @CRLF)
            $HTML = $chars
           ; msgbox(64,"timeout = "&$timer_result,$chars)
        Else
            continueloop
        EndIf
        exitloop
    WEnd
    Return $HTML
endfunc

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  
Followers 0