Next: , Previous: , Up: stdlib io port   [Index]


5.8.2.8 Binary input

Procedure: get-u8 binary-input-port

Read from binary-input-port, blocking as necessary, until a byte is available from binary-input-port or until an end of file is reached. If a byte becomes available, get-u8 returns the byte as an octet and updates binary-input-port to point just past that byte. If no input byte is seen before an end of file is reached, the end–of–file object is returned.

Procedure: lookahead-u8 binary-input-port

The lookahead-u8 procedure is like get-u8, but it does not update binary-input-port to point past the byte.

Procedure: get-bytevector-n binary-input-port count

count must be an exact, non–negative integer object representing the number of bytes to be read.

The get-bytevector-n procedure reads from binary-input-port, blocking as necessary, until count bytes are available from binary-input-port or until an end of file is reached.

If count bytes are available before an end of file, get-bytevector-n returns a bytevector of size count.

If fewer bytes are available before an end of file, get-bytevector-n returns a bytevector containing those bytes. In either case, the input port is updated to point just past the bytes read.

If an end of file is reached before any bytes are available, get-bytevector-n returns the end–of–file object.

Procedure: get-bytevector-n! binary-input-port bytevector start count

count must be an exact, non–negative integer object, representing the number of bytes to be read. bytevector must be a bytevector with at least start+count elements.

The get-bytevector-n! procedure reads from binary-input-port, blocking as necessary, until count bytes are available from binary-input-port or until an end of file is reached.

If count bytes are available before an end of file, they are written into bytevector starting at index start, and the result is count.

If fewer bytes are available before the next end of file, the available bytes are written into bytevector starting at index start, and the result is a number object representing the number of bytes actually read.

In either case, the input port is updated to point just past the bytes read. If an end of file is reached before any bytes are available, get-bytevector-n! returns the end–of–file object.

Procedure: get-bytevector-some binary-input-port

Read from binary-input-port, blocking as necessary, until bytes are available from binary-input-port or until an end of file is reached. If bytes become available, get-bytevector-some returns a freshly allocated bytevector containing the initial available bytes (at least one), and it updates binary-input-port to point just past these bytes. If no input bytes are seen before an end of file is reached, the end–of–file object is returned.

Procedure: get-bytevector-all binary-input-port

Attempts to read all bytes until the next end of file, blocking as necessary. If one or more bytes are read, get-bytevector-all returns a bytevector containing all bytes up to the next end of file. Otherwise, get-bytevector-all returns the end–of–file object. The operation may block indefinitely waiting to see if more bytes will become available, even if some bytes are already available.


Next: , Previous: , Up: stdlib io port   [Index]