up: IO     index Zimbu documentation

CLASS IO.Socket EXTENDS IO.File @public

summary

     

Socket for reading and writing.

Use IO.clientSocket() to create one.

$readByte() int @public  Reads and returns one byte. When there is nothing to read returns IO.eof.
$write(text) status @public  Writes text to the socket. Returns FAIL or OK.
$writeByte(byte) status @public  Writes byte byte to the socket.
$flush() status @public  Flushes buffered output. Sockets do not use buffering, always returns OK.
$close() status @public  Closes the socket, reading/writing will no longer be possible. Returns FAIL when closing failed.
 
Inherited from IO.File:
C(FILE *)  $fd @directory 
 
$readChar() int @public  Reads one UTF-8 character.
$readAll() string @public  Reads the whole file and returns it as a string.
$readAllBytes() byteString @public  Reads the whole file and returns it as a byteString.
$readAll(size) string @public  Reads the file up to size bytes and returns it as a string.
$readLine() string @public  Reads and returns one line, excluding the terminating NL.
$readLineRaw() string @public  Reads and returns one line, including the terminating NL.
$readAllLines() list<string> @public  Reads the whole file and returns a list with all lines.
$readAllLinesRaw() list<string> @public  Reads the whole file and returns a list with all lines.
$readAllLines(count) list<string> @public  Reads the file and returns a list with up to count lines.
$readAllLinesRaw(count) list<string> @public  Reads the file and returns a list with up to count lines.
$writeAllLines(lines) status @public  Writes lines to the file.
$Finish() status @file  Destructor: closes the file if not closed already.
 
Inherited from IO.Writer:
$write(text) status @public  Writes text converted to a string.
$write(number) status @public  Writes number as a decimal number.
$write(number) status @public  Writes number as a decimal number.
$write(number) status @public  Writes number as a decimal number.
$write(flag) status @public  Writes flag as "TRUE" or "FALSE".
$write(ok) status @public  Writes ok as "FAIL" or "OK".
$write(arg) status @public  Writes arg depending on its actual type. Returns FAIL or OK.
$writeChar(char) status @public  Writes char as a UTF-8 byte sequence.
$print(text) status @public  Writes text and appends a newline. Returns FAIL or OK.
$print(number) status @public  Writes number and appends a newline. Returns FAIL or OK.
$print(number) status @public  Writes number and appends a newline. Returns FAIL or OK.
$print(number) status @public  Writes number and appends a newline. Returns FAIL or OK.
$print(flag) status @public  Writes flag as "TRUE" or "FALSE" and appends a newline. Returns FAIL or OK.
$print(ok) status @public  Writes ok as "FAIL" or "OK" and appends a newline. Returns FAIL or OK.
$print(arg) status @public  Writes arg depending on its actual type and appends a newline. Returns FAIL or OK.
$print() status @public  Writes a newline and returns FAIL or OK.
$format(fmt, arguments) status @public  Formats the string and writes it with a newline appended.
 

members (alphabetically)

     

FUNC $close() status @replace @public

     

Closes the socket, reading/writing will no longer be possible. Returns FAIL when closing failed.

When called twice the second one will always return FAIL.

FUNC $flush() status @replace @public

     

Flushes buffered output. Sockets do not use buffering, always returns OK.

FUNC $readByte() int @replace @public

     

Reads and returns one byte. When there is nothing to read returns IO.eof.

FUNC $write(string text) status @replace @public

     

Writes text to the socket. Returns FAIL or OK.

FUNC $writeByte(int byte) status @replace @public

     

Writes byte byte to the socket.

Only the lower 8 bits of byte are used, the rest is ignored. Returns FAIL when the byte could not be written.

license

      Copyright 2009 Bram Moolenaar All Rights Reserved.

      Licensed under the Apache License, Version 2.0. See the LICENSE file or obtain a copy at: http://www.apache.org/licenses/LICENSE-2.0