class CLIENT_SOCKET_INPUT_OUTPUT_STREAM

Features exported to ANY

Direct parents

conformant parents

SOCKET_INPUT_OUTPUT_STREAM

Summary

creation features

exported features

Skipping separators:

To read one number at a time:

To read one line or one word at a time:

Other features:

To write a number:

Other features:

Details

disconnect

Try to disconnect the stream. Note that it *does not* ensure that the stream will effectively be disconnected (some terminal streams, for instance, are always connected) but the feature can be used to "shake off" filters.

require

  • is_connected
  • can_disconnect

ensure

  • not is_filtered

is_connected: BOOLEAN

True if the stream is connected. Only in that case can data be transfered via this stream.

can_unread_character: BOOLEAN
end_of_input: BOOLEAN

end_of_input means the previous attempt in character reading failed because the end has been reached (or temporarily reached). So last_character is not valid and you are not allowed to do any read attempt anymore. (NOTE: just after a successful connect, end_of_input is always false because you never read).

Please refer to SmartEiffel FAQ or tutorial/io examples.

set_timeout (a_timeout: REAL)

require

  • a_timeout >= 0.0

unset_timeout

Makes the socket wait until some characters are available (no timeout)

try_again

Attempt another read. Useful when timeout is set.

require

  • is_connected
  • end_of_input

when_disconnect (handler: PROCEDURE [O_ -> TUPLE][TUPLE 1 [A_][SOCKET_INPUT_OUTPUT_STREAM]])
can_disconnect: BOOLEAN

True if the stream can be safely disconnected (without data loss, etc.)

require

  • is_connected

can_read_character: BOOLEAN
can_read_line: BOOLEAN
valid_last_character: BOOLEAN
can_disconnect: BOOLEAN

True if the stream can be safely disconnected (without data loss, etc.)

require

  • is_connected

read_character

If read_character fail, end_of_input is set. Else, use last_character.

require

  • is_connected
  • not is_filtered and then can_read_character

ensure

  • is_connected

read_line_in (buffer: STRING)

Same job as read_line but storage is directly done in buffer.

require

  • is_connected
  • not is_filtered and then can_read_line
  • buffer /= Void

unread_character

require

  • is_connected
  • not is_filtered and then can_unread_character

ensure

  • not end_of_input

last_character: CHARACTER

require

  • is_connected
  • not end_of_input
  • not is_filtered and then valid_last_character

ensure

  • is_connected
  • not end_of_input

push_back_flag: BOOLEAN
This feature is obsolete: Now please use the more general `can_unread_character' (before may 2005)
detach

Shake off the filter.

ensure

  • not is_filtered

deferred is_connected: BOOLEAN

True if the stream is connected. Only in that case can data be transfered via this stream.

deferred disconnect

Try to disconnect the stream. Note that it *does not* ensure that the stream will effectively be disconnected (some terminal streams, for instance, are always connected) but the feature can be used to "shake off" filters.

require

  • is_connected
  • can_disconnect

ensure

  • not is_filtered

is_filtered: BOOLEAN

True if some filter is using this stream as backend. use that filter instead.

descriptor: INTEGER

Some OS-dependent descriptor. Mainly used by the sequencer library (see READY_CONDITION).

require

  • is_connected
  • has_descriptor

has_descriptor: BOOLEAN

True if that stream can be associated to some OS-meaningful descriptor.

require

  • is_connected

deferred read_character

If read_character fail, end_of_input is set. Else, use last_character.

require

  • is_connected
  • not is_filtered and then can_read_character

deferred read_line_in (buffer: STRING)

Same job as read_line but storage is directly done in buffer.

require

  • is_connected
  • not is_filtered and then can_read_line
  • buffer /= Void

deferred unread_character

require

  • is_connected
  • not is_filtered and then can_unread_character

deferred last_character: CHARACTER

require

  • is_connected
  • not end_of_input
  • not is_filtered and then valid_last_character

deferred can_read_character: BOOLEAN
deferred can_read_line: BOOLEAN
deferred can_unread_character: BOOLEAN
deferred valid_last_character: BOOLEAN
deferred end_of_input: BOOLEAN

end_of_input means the previous attempt in character reading failed because the end has been reached (or temporarily reached). So last_character is not valid and you are not allowed to do any read attempt anymore. (NOTE: just after a successful connect, end_of_input is always false because you never read).

Please refer to SmartEiffel FAQ or tutorial/io examples.

deferred is_filtered: BOOLEAN
deferred is_connected: BOOLEAN
skip_separators

Skip all separators (see is_separator of class CHARACTER) and make the first non-separator available in last_character. This non-separator character is pushed back into the stream (see unread_character) to be available one more time (the next read_character will consider this non-separator). When end_of_input occurs, this process is automatically stopped.

require

  • is_connected
  • not is_filtered

skip_separators_using (separators: STRING)

Same job as skip_separators using the separators set.

require

  • is_connected
  • not is_filtered
  • separators /= Void

skip_remainder_of_line

Skip all the remainder of the line including the end of line delimiter itself.

require

  • is_connected
  • not is_filtered

read_integer

Read an integer according to the Eiffel syntax. Make result available in last_integer. Heading separators are automatically skipped using is_separator of class CHARACTER. Trailing separators are not skipped.

require

  • is_connected
  • not is_filtered

ensure

  • old end_of_input implies end_of_input and then not valid_last_integer

last_integer: INTEGER

Last integer read using read_integer.

valid_last_integer: BOOLEAN

Was the last call to read_integer successful ?

read_double
This feature is obsolete: Now use `read_real / last_real' only. October 3rd 2004. No more DOUBLE type mark.
last_double: REAL
This feature is obsolete: Now use `read_real / last_real' only. October 3rd 2004. No more DOUBLE type mark.
last_real: REAL

Last real read with read_real.

valid_last_real: BOOLEAN

Was the last call to read_real successful ?

read_real

Read a REAL and make the result available in last_real.

require

  • is_connected
  • not is_filtered

ensure

  • old end_of_input implies end_of_input and then not valid_last_real

last_string: STRING

Access to the unique common buffer to get for example the result computed by read_line, read_word, newline, etc. This is a once function (the same common buffer is used for all streams).

read_line

Read a complete line ended by '%N' or end_of_input. Make the result available in last_string common buffer. The end of line character (usually '%N') is not added in the last_string buffer.

require

  • is_connected
  • not is_filtered

read_word

Read a word using is_separator of class CHARACTER. The result is available in the last_string common buffer. Heading separators are automatically skipped. Trailing separators are not skipped (last_character is left on the first one). If end_of_input is encountered, Result can be the empty string.

require

  • is_connected
  • not is_filtered

newline

Consume input until newline ('%N') is found. The corresponding STRING is stored in last_string common buffer.

require

  • is_connected
  • not is_filtered

reach_and_skip (keyword: STRING)

Try to skip enough characters in order to reach the keyword which is skipped too. If the keyword is not in the remainder of this stream, the process is stopped as soon as end_of_input occurs. As for skip_separators the following character of the keyword is available in last_character and not yet read.

require

  • is_connected
  • not is_filtered
  • not keyword.is_empty

ensure

  • not end_of_input implies last_string.is_equal(keyword)

read_word_using (separators: STRING)

Same job as read_word using separators.

require

  • is_connected
  • not is_filtered
  • separators /= Void

read_tail_in (str: STRING)

Read all remaining character of the stream in str.

require

  • is_connected
  • not is_filtered
  • str /= Void

ensure

  • end_of_input

can_put_character (c: CHARACTER): BOOLEAN
can_disconnect: BOOLEAN

True if the stream can be safely disconnected (without data loss, etc.)

require

  • is_connected

put_character (c: CHARACTER)

require

  • is_connected
  • not is_filtered and then can_put_character(c)

flush

Flushes the pipe. If output_is_filtered, calls the filter's flush instead.

require

  • is_connected

detach

Shake off the filter.

ensure

  • not is_filtered

deferred put_character (c: CHARACTER)

require

  • is_connected
  • not is_filtered and then can_put_character(c)

deferred flush

Flushes the pipe. If output_is_filtered, calls the filter's flush instead.

require

  • is_connected

deferred can_put_character (c: CHARACTER): BOOLEAN
deferred is_filtered: BOOLEAN
deferred is_connected: BOOLEAN
put_string (s: STRING)

Output s to current output device.

require

  • is_connected
  • not is_filtered
  • s /= Void

put_unicode_string (unicode_string: UNICODE_STRING)

Output the UTF-8 encoding of the unicode_string.

require

  • is_connected
  • not is_filtered
  • unicode_string /= Void

put_line (s: STRING)

Output the string followed by a '%N'.

frozen put_integer (i: INTEGER_64)

Output i to current output device.

require

  • is_connected
  • not is_filtered

frozen put_integer_format (i: INTEGER_64, s: INTEGER)

Output i to current output device using at most s character.

require

  • is_connected
  • not is_filtered

put_real (r: REAL)

Output r to current output device.

require

  • is_connected
  • not is_filtered

put_real_format (r: REAL, f: INTEGER)

Output r with only f digit for the fractionnal part. Examples:

   put_real(3.519,2) print "3.51".

require

  • is_connected
  • not is_filtered
  • f >= 0

put_double (d: REAL)
This feature is obsolete: Now use `put_real' (October 2004).
put_double_format (d: REAL, f: INTEGER)
This feature is obsolete: Now use `put_real_format' (October 2004).
put_real_scientific (r: REAL, f: INTEGER)

Output r using the scientific notation with only f digit for the fractionnal part. Examples:

   put_real_scientific(3.519,2) print "3.16e+00".

require

  • is_connected
  • not is_filtered
  • f >= 0

put_number (number: NUMBER)

Output the number.

require

  • is_connected
  • not is_filtered
  • number /= Void

put_boolean (b: BOOLEAN)

Output b to current output device according to the Eiffel format.

require

  • is_connected
  • not is_filtered

put_pointer (p: POINTER)

Output a viewable version of p.

require

  • is_connected
  • not is_filtered

put_new_line

Output a newline character.

require

  • is_connected
  • not is_filtered

put_spaces (nb: INTEGER)

Output nb spaces character.

require

  • is_connected
  • not is_filtered
  • nb >= 0

append_file (file_name: STRING)

require

  • is_connected
  • not is_filtered
  • (create {FILE_TOOLS}.default_create).is_readable(file_name)

Class invariant