SUMMARY: MODULE | CLASS | TYPE | PROC | VAR | CONST | DETAIL: TYPE | PROC | VAR | CONST

# IO:Buffer

### Import List

        Ascii
        IO
        Object
        Object

Class List
Channel |

Class Summary: Channel [Detail]
      +---IO.Channel
           |
           +---IO.ByteChannel
                |
                +--IO:Buffer.Channel
Field Summary
base-: ByteChannel
Inherited Fields
From IO.Channel: readyOps
Constructor Summary
Open(ByteChannel): Channel
Method Summary
Close() Cancel all selection keys registered for the channel ch and close the channel.
CloseAndRegister() Like Channel.Close, but register the channel's target with its naming service once done.
FileDescriptor(): FileDescriptor Return the file descriptor of the channel.
Flush() Flush all buffers associated with channel ch.
INIT(ByteChannel)
Read(VAR ARRAY OF BYTE, LONGINT, LONGINT): LONGINT Read a sequence of bytes from the channel into the buffer.
ReadLineLF(): String8 Read one entire line from the channel.
SetBlocking(BOOLEAN) Change the channel's blocking mode.
SetPos(LONGINT) Change the channels position to pos.
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

Class Detail: Channel

Field Detail

### base

    FIELD base-: ByteChannel

Constructor Detail

### Open

    PROCEDURE Open(base: ByteChannel): Channel

Method Detail

### Close

    PROCEDURE (ch: Channel) Close()
      RAISES Error;

> Cancel all selection keys registered for the channel ch and close the channel.

> [Description inherited from Close]

> Redefines: Close, Close

### CloseAndRegister

    PROCEDURE (ch: Channel) CloseAndRegister()
      RAISES Error;

> Like Channel.Close, but register the channel's target with its naming service once done. Right now, only IO:FileChannel supports this feature; see IO:FileChannel.tmpFile for details. By default, this method simply calls Channel.Close.

> [Description inherited from CloseAndRegister]

> Redefines: CloseAndRegister, CloseAndRegister

### 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

### Flush

    PROCEDURE (ch: Channel) Flush()
      RAISES Error;

> Flush all buffers associated with channel ch.

> [Description inherited from Flush]

> Redefines: Flush

### INIT

    PROCEDURE (ch: Channel) INIT(base: ByteChannel)

> 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

### ReadLineLF

    PROCEDURE (ch: Channel) ReadLineLF(): String8
      RAISES Error;

> Read one entire line from the channel. The line after the first line-feed character (Ascii.lf; that is, a trailing line-feed is kept in the string. If the channel ends with an incomplete line, then the line-feed character is absent from the last line. NIL is returned after the last line of the channel has been read.

> Note: The returned string contains null characters (``0X`') if they occurred in the input.

### 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

### SetPos

    PROCEDURE (ch: Channel) SetPos(pos: LONGINT)
      RAISES Error;

> Change the channels position to pos.

> [Description inherited from SetPos]

> Redefines: SetPos, SetPos

### 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