Creating a Channel

The process of creating a ChannelChannel is straightforward. As you might expect, it uses the constructor function astChannelastChannel:


\begin{terminalv}
...

The first two arguments to astChannel specify the external source and sink that the Channel is to use. There arguments are pointers to C functions and we will examine their use in more detail later (§15.13 and §15.14).

In this very simple example we have supplied NULL pointers for both the source and sink functions. This requests the default behaviour, which means that textual input will be read from the program's standard input stream (typically, this means your keyboard) while textual output will go to the standard output stream (typically appearing on your screen). On UNIX systems, of course, either of these streams can easily be redirected to files. This default behaviour can be changed by assigning values to the Channel's SinkFileSinkFile and/or SourceFileSourceFile attributes. These attributes specify the paths to text files that are to be used in place of the standard input and output streams.