taurus905 Posted October 1, 2022 Share Posted October 1, 2022 I dusted off an old script I wrote in 2017, which still works. However, I noticed that it could be much faster if I incorporate a way to have _InetGetSource timeout after a second of two. I read some older posts on this subject, but couldn't determine a simple and elegant method of achieving my goal. Thank you in advance for any constructive ideas you have to offer. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
TheXman Posted October 1, 2022 Share Posted October 1, 2022 (edited) 1 hour ago, taurus905 said: incorporate a way to have _InetGetSource timeout after a second of two I don't know of a way to change the timeout settings for the _InetGetSource() function itself. However, if I needed control over HTTP request timeouts, I would most likely use the WinHTTPRequest object instead of _InetGetSource(). Specifically, I would use the SetTimeouts method of the object to set the desired timeouts. As you can see HERE, there's more than 1 timeout for a request. The SetTimeouts method allows you to set them as you desire. It would look something like this: ... $oHttp.SetTimeouts(5000, 5000, 5000, 5000) ... Edited October 1, 2022 by TheXman taurus905 and Musashi 2 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
taurus905 Posted October 2, 2022 Author Share Posted October 2, 2022 On 10/1/2022 at 1:28 PM, TheXman said: However, if I needed control over HTTP request timeouts, I would most likely use the WinHTTPRequest object instead of _InetGetSource(). @TheXman Thank you for "once again" pointing me in the right direction. Using the WinHTTPRequest object is much cleaner and gives me more control. I also found a post by @Nine that reminded me of "object error handling" which I needed in this case. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
argumentum Posted October 3, 2022 Share Posted October 3, 2022 (edited) On 10/1/2022 at 2:15 PM, taurus905 said: it could be much faster if I incorporate a way to have _InetGetSource timeout after a second of two ..or, Fork / IPC, those pesky time consuming tasks. I know the question got answered but, ... I think the above is a good idea anyway. Edited October 3, 2022 by argumentum taurus905 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
taurus905 Posted October 3, 2022 Author Share Posted October 3, 2022 1 hour ago, argumentum said: I know the question got answered but, ... I think the above is a good idea anyway. Thank you @argumentum Please elaborate or just point me in the right direction. I'd love to learn how to "Fork / IPC, those pesky time consuming tasks." taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
argumentum Posted October 3, 2022 Share Posted October 3, 2022 .. there is a ping thing using forking. I've put together a UDF for forking and IPC, Just look at my signature and search for "fork". taurus905 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
jugador Posted October 3, 2022 Share Posted October 3, 2022 Func __Example1A() ConsoleWrite(__InetGet("https://www.autoitscript.com/forum/")& @CRLF) ; ConsoleWrite(__InetGet("https://www.autoitscript.com/forum/", 2000)& @CRLF) EndFunc Func __InetGet($e_Url, $e_TimeOut = 10000) Local $e_FPath = @ScriptDir & '\Temp_InetGet.txt' If Not FileExists($e_FPath) Then Local $e_FOpen = FileOpen($e_FPath, 1) FileClose($e_FOpen) Endif Local $e_TFlag = True Local $e_IGetData = InetGet($e_Url, $e_FPath, 1, 1) Local $e_Timer = TimerInit() Do If TimerDiff( $e_Timer) > $e_TimeOut Then $e_TFlag = False ExitLoop EndIf Sleep(10) Until InetGetInfo($e_IGetData, 2) Local $iMsg = '@error: Timeout' If $e_TFlag Then $iMsg = FileRead($e_FPath) InetClose($e_IGetData) FileDelete($e_FPath) Return $iMsg EndFunc taurus905 1 Link to comment Share on other sites More sharing options...
taurus905 Posted October 3, 2022 Author Share Posted October 3, 2022 @jugador I'm always looking for new ways to complete my tasks. I will give your solution a try later today. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now