prev back next

Stream classes

Streams offer a means to sequentially access elements of a collection. Also, there are classes to access files, directories, pipes or sockets.

The most useful stream classes are:

Use the systemBrowser to have a more detailed look into the implementation.

ReadStream

ReadStreams can be used to process elements of a collection sequentially.
The typical use of readStreams is:

WriteStream

WriteStreams can be used to collect elements in a collection.
The typical use of writeStreams is:

ExternalStream

This is an abstract class - i.e. there are no instances of ExternalStream. Instead, it provides the common behavior for all streams which are associated with an external (OperatingSystem-) stream. Examples are FileStream, PipeStream, Socket and DirectoryStream.
Therefore, the following protocol is valid for all off the above mentioned classes.
ExternalStreams elements are normally characters, however, they also support a so called binary mode in which byte-valued integers are processed.
Typical operations:

FileStream

FileStreams support all of ExternalStreams protocol. The can be created to read, write, readWrite or append from/to a file.
Creation:

For portability, you should use the companion class Filename to create fileStreams:

PipeStream

PipeStreams allow reading the output of any unix command or sending text for input to a unix command. Once created, they behave like any other ExternalStream.
Creation:

Socket

Sockets allow the sending/receiving of unstructured data via TCP/IP connections.
Due to a somewhat more complex naming and connection procedure, the protocol for Socket creation is a bit more complex than for the above streams. See examples in the "doc/coding" directory for more details.

Copyright © Claus Gittinger Development & Consulting, all rights reserved

(cg@ssw.de)