get-bytevector-n, read-bytevector - read data from a binary port
(import (rnrs)) ;R6RS
(import (rnrs io ports)) ;R6RS
(import (scheme base)) ;R7RS
(get-bytevector-n binary-input-port k)
(read-bytevector k binary-input-port)
blocking as necessary, until
bytes are available from
or until an end of file is reached.
If an end of file is reached before any bytes are available
then the end-of-file object is returned.
The input port is updated to point just past the bytes read.
The default value for
is the object returned by
- Multiple end-of-file conditions
The port may return an end-of-file object and then still keep
producing data if another read is attempted. Files do not normally
work this way, but it is possible for other types of ports to do so,
such as terminals. R6RS explicitly mentions this situation while R7RS
Returns a single value; a bytevector or an end-of-file object. An
empty bytevector is returned if
There is a single, unique end-of-file object.
(call-with-port (open-file-input-port "/dev/zero")
(get-bytevector-n p 4)))
=> #vu8(0 0 0 0)
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain.
must be an exact, nonnegative integer object, and
must be an open binary input port.
- &i/o-read (R6RS)
There was an I/O error during the read operation.
- &i/o-port (R6RS)
This condition specifies the port object related to an
The assertions described above are errors.
Implementations may signal an error, extend the procedure's
domain of definition to include such arguments,
or fail catastrophically.
Reports prior to R6RS did not support binary I/O.
This page is part of the
It includes materials from the RnRS documents.
More information can be found at
The default port used by
is the current input port, which is normally a textual port that is
not expected to support binary I/O.
Markup created by unroff 1.0sc, March 04, 2023.