Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

ftp dowlnoad of large file and read-io ....

 [1/3] from: petr::krenzelok::trz::cz at: 12-Sep-2001 13:23


Hi, So I just rewrote core.pdf example of ftp download of large file, and it doesn't work, unless I clear the buffer each time. What am I doing wrong? buf-size: 20000 buffer: make string! buf-size source: open/direct ftp-site target: open/new/direct join target-path [trim fl/text ".tra"] total: 0 size: 0 start: now/time while [not zero? size: read-io source buffer buf-size][ write-io target buffer size clear buffer total: total + size p/text: to-string total t/text: to-string now/time - start show p show t ] The problem is, that if I don't "clear buffer", the download of each file stops at some 20479, and server probably closes the connection. It even doesn't matter, if I define buffer as binary type, of size buf-size + 2 (btw: what is that additional 2 good for?) Everything seems to work, once I add "clear buffer" line as above. The question is - what is going on? Thanks a lot, -pekr-

 [2/3] from: m:koopmans2:chello:nl at: 12-Sep-2001 14:07


Buffer is declared as a string of 20000. read-io does an append on your buffer, but as it is low-level (?) it does not dynamically enlarge your buffer, so at 20.000 + a little bit it sees that your buffer is full and stops reading. Try it with smaller sizes, you'll see the same. Buffer is a buffer after all, so it is what you want for high performance things. Note that without clearing buffer you are resending things you have read earlier (unless write-io is smart about this). But... you got it right now HTH, Maarten

 [3/3] from: g:santilli:tiscalinet:it at: 12-Sep-2001 14:04


Petr Krenzelok wrote: (Dunno if this will arrive to you. US is currently out of reach for me, hope it will get to Czech Rep. at least.)
> So I just rewrote core.pdf example of ftp download of large file, and it > doesn't work, unless I clear the buffer each time. What am I doing > wrong?
AFAIK READ-IO *appends* to the buffer you provide. (It doesn't, however, enlarge it.) So you have to clear it each time, or make it big enough to keep the whole file (when applicable :). HTH, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/