| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The underlying mechanism of procedural ports is very flexible, but I don't have Scheme interface yet, except the following ones:
These are the Scheme interface to the "buffered port".
open-input-buffered-port creates and returns an input port,
with associated buffer of size buffer-size.
The data is read from the buffer.
When the port is read and the buffer is empty, a procedure filler
is called with one argument, the size of required data.
filler must return a string (either complete or incomplete)
of the specified size. It is permitted for filler
to return a string shorter than the size, if not enough data is available.
The behavior is undefined if filler returns larger string than
specified. Note that the size of string matters, not the length
of string.
If filler finds that it reached EOF of its data source, it can
return EOF. Retuning zero size string has the same effect as EOF.
Initially, the buffer is empty, so filler is always called
at the first attempt of reading from the port.
open-output-buffered-port creates and returns an output port,
with associated buffer of size buffer-size.
The data output to the port is accumulated in the buffer.
When the buffer gets full, or flush is called on the port,
a procedure flusher is called with an incomplete string
to be flushed. flusher must return a number of bytes flushed,
which must be the same as the size of the passed string.
The string may shorter than buffer-size.
When the port is closed, flusher is called with any data
remaining in the buffer, then it is called again with #f to
indicate the port is closed.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |