1 Language Model
2 Syntactic Forms
3 Datatypes
4 Structures
5 Classes and Objects
6 Units
7 Contracts
8 Pattern Matching
9 Control Flow
10 Concurrency
11 Macros
12 Input and Output
13 Reflection and Security
14 Operating System
15 Memory Management
16 Running PLT Scheme
Bibliography
Index
Version: 4.0.2

 

12.1 Ports

Ports produce and consume bytes. When a port is provided to a character-based operation, the port’s bytes are decoded; see Encodings and Locales.

The global variable eof is bound to the end-of-file value, and eof-object? returns #t only when applied to this value. Reading from a port produces an end-of-file result when the port has no more data, but some ports may also return end-of-file mid-stream. For example, a port connected to a Unix terminal returns an end-of-file when the user types control-D; if the user provides more input, the port returns additional bytes after the end-of-file.

Every port has a name, as reported by object-name. The name can be any value, and it is used mostly for error-reporting purposes. The read-syntax procedure uses the name of an input port as the default source location for the syntax objects that it produces.

    12.1.1 Encodings and Locales

    12.1.2 Managing Ports

    12.1.3 Port Buffers and Positions

    12.1.4 Counting Positions, Lines, and Columns

    12.1.5 File Ports

    12.1.6 String Ports

    12.1.7 Pipes

    12.1.8 Structures as Ports

    12.1.9 Custom Ports

    12.1.10 More Port Constructors and Events

      12.1.10.1 Creating Ports

      12.1.10.2 Port Events

      12.1.10.3 Copying Streams