[Coldstuff] suspending tasks
coldstuff@cold.org
coldstuff@cold.org
Wed, 24 Jul 2002 09:38:35 -0700 (PDT)
On Wed, 24 July 2002, Bruce Mitchener wrote
> Don't use cwritef() or whatever it was that dumps the file to the
> connection in one shot. Open the file, read from it, write the data to
> the network, and loop on that with a pause() in there. You'll have to
> come up with what you think is a good chunksize to write each iteration
> through the loop.
It's reading the file that's slow, not writing to the connection.
(Or, does sending a paragraph to a 300-baud modem cause immense systemwide
lag!?)
This is all very core-specific, but your code might look something like this:
blocksize = 8192;
file = $file_system.fopen(filename);
while(!file.feof()) {
pause();
connection.cwrite(file.fread(blocksize));
}
Of course, it would be very nice to have a pause-implied fread() and
cwritef(), along with the horrible $network.hostname().
- Kipp