Usage

The base.Channel class is a built-in class providing basic input/output functionality for:
  • text file reading/writing
  • subprocess communication (through pipes)
  • basic network communication (through TCP sockets)

No character set conversion is done when reading or writing data with channel objects. The character set used by the other end of the channel must correspond to the locale of the runtime system, for both input and output. For more details, see Character string encoding.

Steps to use a channel object:
  • Define a variable with the base.Channel type.
  • Create a channel object with base.Channel.create() and assign it to the variable.
  • Open the channel for a file, piped process or socket (as a client).
  • Read and/or write data on the channel.
  • Close the channel.

When reading or writing character strings, the escape character is the backslash (\).

The are three modes to read and write data with Channels:
  1. Reading/writing formatted data as a set of fields in a line (records), with the read() and write() methods.
  2. Reading/writing complete lines with the readLine() and writeLine() methods.
  3. Handling raw character string data by reading/writing pieces of strings, with the readOctets() and writeNoNL() methods.

Channels may raise exceptions that can be trapped with WHENEVER ERROR or TRY/CATCH blocks.

An extension class it provided to get better control over server TCP socket management with the util.Channels class.