Socket timeout not working with libUrl

Sarah Reichelt sarahr at genesearch.com.au
Sun Jan 30 18:25:29 EST 2005


> My product pings the Web Photos Pro website to look for new versions.  
> This works great when the computer the product's running on is 
> connected to the internet, but it hangs for 60 seconds when there's no 
> net connection.
>
> My code looks like this:
>
>   set the socketTimeoutInterval to 5000
>   put URL (getPhotoAlbumUrl() & "downloads/version_info.php") into 
> newVersion
>
> Is there any way I can force a timeout after 5 seconds?  Should I be 
> using a non-blocking URL request?  Should I be attempting to open a 
> socket directly to do an initial "am I connected to the internet?" 
> request, before making the URL request?
>

Hi Frank,

I would definitely use a non-blocking request, so the user won't even 
notice if it is trying & failing.
Try something like:
   set the socketTimeoutInterval to 5000
   put (getPhotoAlbumUrl() & "downloads/version_info.php") into tURL
   load tURL with message gotVersion

Then you need a "gotVersion" handler in the same object:

on gotVersion
   put URL (getPhotoAlbumUrl() & "downloads/version_info.php") into 
newVersion
   -- check newVersion & do the usual stuff
end gotVersion

Hope this helps,
Sarah



More information about the Use-livecode mailing list