An interactive port is always in one of two modes: blocking or non-blocking. This mode is independent of the terminal mode: each can be changed independently of the other. Furthermore, if it is an interactive I/O port, there are separate blocking modes for input and for output.
If an input port is in blocking mode, attempting to read from it when no input is available will cause Scheme to “block”, i.e. suspend itself, until input is available. If an input port is in non-blocking mode, attempting to read from it when no input is available will cause the reading procedure to return immediately, indicating the lack of input in some way (exactly how this situation is indicated is separately specified for each procedure or operation).
An output port in blocking mode will block if the output device is not ready to accept output. In non-blocking mode it will return immediately after performing as much output as the device will allow (again, each procedure or operation reports this situation in its own way).
Interactive ports are initially in blocking mode; this can be changed at any time with the procedures defined in this section.
These procedures represent blocking mode by the symbol
and non-blocking mode by the symbol
nonblocking. An argument
called mode must be one of these symbols. A port argument
to any of these procedures may be any port, even if that port does not
support blocking mode; in that case, the port is not modified in any
Returns the blocking mode of input-port or output-port.
#f if the given port doesn’t support blocking mode.
Changes the blocking mode of input-port or output-port to be mode and returns an unspecified value.
Thunk must be a procedure of no arguments.
Binds the blocking mode of input-port or output-port to be mode, and calls thunk. When thunk returns, the original blocking mode is restored and the values yielded by thunk are returned.
These procedures are deprecated; instead use the corresponding procedures above.