IO:StdChannels

Import List

    IO
 
Class List
Channel
Class Summary: Channel [Detail]
  +---IO.Channel
       |
       +---IO.ByteChannel
            |
            +--IO:StdChannels.Channel
Inherited Fields

From IO.Channel:

          readyOps

Method Summary
FileDescriptor(): FileDescriptor

          Return the file descriptor of the channel.
INIT(FileDescriptor)

          
Read(VAR ARRAY OF BYTE, LONGINT, LONGINT): LONGINT

          Read a sequence of bytes from the channel into the buffer.
SetBlocking(BOOLEAN)

          Change the channel's blocking mode.
Write(ARRAY OF BYTE, LONGINT, LONGINT): LONGINT

          Write a sequence of bytes to this channel from the buffer.
Inherited Methods

From IO.Channel:

          Close, CloseAndRegister, FileDescriptor, KeyForSelector, RegisterWithSelector, SetBlocking, SetPos

From IO.ByteChannel:

          Flush, INIT, Read, TransferTo, Write

 
Procedure Summary
IOError(STRING)

          
Variable Summary
stderr-: ByteChannel

          
stdin-: ByteChannel

          
stdout-: ByteChannel

          

Class Detail: Channel
Method Detail

FileDescriptor

PROCEDURE (ch: Channel) FileDescriptor(): FileDescriptor

Return the file descriptor of the channel. This is the integer number that is used to identify the channel on the level of the C library. If the channel is not associated with a file descriptor, result is `-1'.

[Description inherited from FileDescriptor]

Redefines: FileDescriptor, FileDescriptor


INIT

PROCEDURE (ch: Channel) INIT(fd: FileDescriptor)

Redefines: INIT, INIT


Read

PROCEDURE (ch: Channel) Read(VAR buffer: ARRAY OF BYTE; 
               start: LONGINT; 
               length: LONGINT): LONGINT
  RAISES Error;

Read a sequence of bytes from the channel into the buffer.

An attempt is made to read up to length bytes from the channel. The bytes are written to buffer, starting at position start. Result is the number of bytes actually read, or `-1' if the read position is at the end of the channel, and length is not zero.

A read operation might not read length bytes, and in fact it might not read any bytes at all. Whether or not it does so depends upon the nature and state of the channel. A socket channel in non-blocking mode, for example, cannot read any more bytes than are immediately available from the socket's input buffer; similarly, a file channel cannot read any more bytes than remain in the file. It is guaranteed, however, that if a channel is in blocking mode and there is at least one byte remaining in the buffer then this method will block until at least one byte is read.

Pre-condition: `0 <= start <= start+length <= LEN(buffer)' and `length >= 0'.

[Description inherited from Read]

Redefines: Read


SetBlocking

PROCEDURE (ch: Channel) SetBlocking(block: BOOLEAN)
  RAISES Error;

Change the channel's blocking mode. Channels typically default to blocking mode on creation.

If a channel does not support non-blocking operation, then any call to this method is ignored. Rider implementations from IO:BinaryRider and IO:TextRider only work with blocking channels.

[Description inherited from SetBlocking]

Redefines: SetBlocking, SetBlocking


Write

PROCEDURE (ch: Channel) Write(buffer: ARRAY OF BYTE; 
                start: LONGINT; 
                length: LONGINT): LONGINT
  RAISES Error;

Write a sequence of bytes to this channel from the buffer.

An attempt is made to write up to length bytes to the channel. The bytes are taken from buffer, beginning at position start.

A write operation can return after writing less than length bytes. That is, some types of channels, depending upon their state, may write only some of the bytes or possibly none at all. A socket channel in non-blocking mode, for example, cannot write any more bytes than are free in the socket's output buffer. Result is the number of bytes actually written.

Pre-condition: `0 <= start <= start+length <= LEN(buffer)' and `length >= 0'.

[Description inherited from Write]

Redefines: Write

 
Procedure Detail

IOError

PROCEDURE IOError(suffix: STRING)
  RAISES Error;
Variable Detail

stderr

VAR stderr-: ByteChannel

stdin

VAR stdin-: ByteChannel

stdout

VAR stdout-: ByteChannel