Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Buffer mystery!
Pages: [1] Print
Author Topic: Buffer mystery!  (Read 437 times)
Guest_leke
Guest


Email
Buffer mystery!
« on: February 23, 2006, 01:18:37 AM »


Regarding READ’s refinement:
/direct -- Opens the port without buffering.

I kind of know that a buffer is a place a script might store data, in either memory or a temporary file whilst being written. So when I got an ‘out of memory error’ in one of my scripts, I used this refinement to solve the problem.

So if I had buffering ‘turned off’, where was the data in my script being stored?
Whilst I am asking, would there be any way to count the bytes as they are being read?

Thanks.

Logged
Gregg
Newbie
*
Offline Offline

Posts: 27


View Profile WWW
Re: Buffer mystery!
« Reply #1 on: April 24, 2006, 07:38:01 PM »

If you use /direct mode, the only place the data is buffered is in your variables (words you set, that refer to the data you've read), so you can buffer up as much data as you want, and dump it to recover memory once you're done with it.

Logged
Anton
Jr. Member
**
Offline Offline

Posts: 66

Rebol veteran


View Profile WWW
Re: Buffer mystery!
« Reply #2 on: August 21, 2006, 01:23:19 AM »

It's not a simple example anymore, but it might just do what you want, too:

http://anton.wildit.net.au/rebol/util/batch-download.r
http://anton.wildit.net.au/rebol/util/demo-batch-download.r

This defines a BATCH-DOWNLOAD function which opens a window to download any number of urls in order, resuming when necessary. It opens the port to the url using direct mode and determines the total length with:

    total-size: to-integer port/locals/headers/content-length

Later it uses copy/part to specify a buffer size and if data was returned the data can be examined to find the length.
Logged
Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Buffer mystery!
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 03, 2008, 11:30:19 PM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2315 Posts in 597 Topics by 4205 Members
Latest Member: TimTearton

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc