Sign in to follow this  
Followers 0
CliftonL

InetGetInfo() Not getting

1 post in this topic

Hi,

I'm having trouble with this code which is supposed to download an auto update installation file from my server. It seems that InetGetInfo() does not always return the bytes transferred the loop times out. I've allowed a generous time of 20 seconds for the timeout, but debugging indicates the bytes transferred are always 0 when this times out.

Admittedly, this doesn't happen for all my clients, seems like the main issue is for those behind proxies. I've forced the headers on my server to set max-age=0 for the download file and turned off proxy caching.

$fileSz = InetGetSize($webFile, 1)

$hDownload = InetGet($webFile, $tmpFile, 1, 1) ;BEGIN DOWNLOADING IN BACKGROUND

Sleep(250)

$pMsg = "  of  " & $fileSz
$pMsg2 = @LF & "Press ESC to cancel update."
ProgressOn("Updating PowerPac ...", "Downloading installation file ... ", "Bytes transferred: 0" & $pMsg & $pMsg2, -1, -1, 16)

$timeStamp = TimerInit() ;SET A TIMER IF NO BYTES ARE TRANSFERRED
$timeout = False

While 1
    Sleep(120)
    $bytes = InetGetInfo($hDownload, 0) ;THIS FAILS FOR SOME CLIENTS?????

    If $bytes = $preBytes And TimerDiff($timeStamp) >= 20000 Then ;Times out at 20 seconds
        $timeout = true ;Sets timeout flag. Later determines the error message to display.
        ExitLoop ;NOTE: DESPITE FILE BEING AVAILABLE SOME CLIENTS GET TIMEDOUT BECAUSE $bytes = 0
    ElseIf $bytes = $preBytes Then
        ContinueLoop
    Else
        $preBytes = $bytes
        $timeStamp = TimerInit()
    EndIf

    ProgressSet(($bytes / $fileSz) * 100, "Bytes transferred: " & $bytes & $pMsg & $pMsg2)
    If $bytes = $fileSz Then ExitLoop

    If _IsPressed("1B") Then ;USER PRESSED <ESC> TO CANCEL THE UPDATE PROCESS!
        InetClose($hDownload)
        FileDelete($tmpFile)
        Exit
    EndIf
WEnd
ProgressOff()

;AT THIS POINT $bytes = 0 and timeout occurs on some client machines??? Indicates download failed?

Ideas gratefully appreciated.

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