Sockets - A few Questions

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Sockets - A few Questions

Post by sturgis » Fri Jul 27, 2012 2:41 am

Hey, this is true, I may just do that. Though the main issue I was concerned about before was the filing up of memory with un-loadable cache. This won't be a problem apparently.

I do think though that a self built cache could be very handy so yep. Time for a project.

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: Sockets - A few Questions

Post by Simon Knight » Fri Jul 27, 2012 7:54 am

Phew!
I'm just about following..... Your discussion about building cache confuses me. Am I correct that the principle benefit of a cache is that a large download is stored in a number of smaller parts. If the connection is lost then remade the download restarts from the end of the data cached. I don't understand how it is possible to gain access to the partially downloaded data.

Simon
best wishes
Skids

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Sockets - A few Questions

Post by shaosean » Fri Jul 27, 2012 9:02 am

Depends on how you want the cache to work.. Simplest form is to just store whatever you downloaded either in a variable or as a temporary file.. When downloading a webpage, you may only want to cache the images and not worry about the HTML and CSS files due to their small sizes.. Some servers will allow you to request a byte marker to resume a transfer, so even if you only cache half a web page, you can just request the rest of the data and append it to what you already have.. So many options, so much fun :-D

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Sockets - A few Questions

Post by sturgis » Fri Jul 27, 2012 2:39 pm

No partial downloads in this case, mainly would just be duplicating the desktop version of the cache for speed purposes. When the message fires on load complete, put the contents into an array tagged with url etc. Then write a function to do URL interactiosn that check if the url has already been cached, grab the data from the array, otherwise hit the server. Of course this is only useful for static pages. For example if I had a help site for my app I could use load to pre-load the help pages, then all future accesses would be local and super fast.

For the purposes of the gps tracking it doesn't really apply though, just use load, catch the data when its done and this way you get the asynchronous advantage of using load, but since it doesn't cache on android or ios, no worries about having to 'unload' to avoid filling up memory.

Having looked at the liburl script, its over my head but a simpler version is within reach I believe.

Post Reply