Sign in to follow this  
Followers 0
qwerz123

InetGetInfo doesn't return bytes read so far

3 posts in this topic

Hello!

I need to create a script that just check the internet connection. I was thinking that i don't need to wait till all the bytes are downloaded. Just if some of them are downloaded - it's enough and internet working fine. So i created a simple script for testing:

Local $bytesRead = 0
Local $hDownload1 = InetGet("http://www.autoitscript.com/autoit3/files/beta/update.dat", @TempDir & "\update.dat", 1, 1)

While $bytesRead = 0
   $bytesRead = InetGetInfo($hDownload1, 0)
   ConsoleWrite("In While. Bytes read: " & $bytesRead & @CRLF)
WEnd

InetClose($hDownload1) ; Close the handle to release resources.

In real script i will add the Sleep function but for testing purposes it is without it.

So in my console i see only this:

In While. Bytes read: 0

In While. Bytes read: 0

In While. Bytes read: 0

... etc the same

In While. Bytes read: 452

So for some reason the function does not return the bytes read so far and only return when the whole downloading is complete.

Could anyone help me or point me where i did the mistake?

Best regards

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

I'd hazard a guess that 452 bytes is downloaded in one chunk, there's nothing, then 452 bytes.

 

Yes, you're right. I just tested with a little different script.

While $bytesRead = 0
   $bytesRead = InetGetInfo($hDownload1, 0)
WEnd

Do
    Sleep(250)
Until InetGetInfo($hDownload1, 2) ; Check if the download is complete.

Local $total = InetGetInfo($hDownload1, 0)

InetClose($hDownload1) ; Close the handle to release resources.

ConsoleWrite("Bytes read: " & $bytesRead & @CRLF)
ConsoleWrite("Total: " & $total & @CRLF)

And it gave me:

Bytes read: 3806
Total: 176351
 
So yes, your answer is correct.
 
Best regards
Edited by qwerz123

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