IOStream
Object Hierarchy:
Description:
public class IOStream :
Object
GIOStream represents an object that has both read and write streams. Generally the two streams acts as separate input and output streams,
but they share some common resources and state. For instance, for seekable streams they may use the same position in both streams.
Examples of IOStream objects are
SocketConnection which represents a two-way network connection, and FileIOStream
which represent a file handle opened in read-write mode.
To do the actual reading and writing you need to get the substreams with
get_input_stream and
get_output_stream.
The IOStream object owns the input and the output streams, not the other way around, so
keeping the substreams alive will not keep the IOStream object alive. If the
IOStream object is freed it will be closed, thus closing the substream, so even if the
substreams stay alive they will always just return a CLOSED for all operations.
To close a stream use close which will close the common stream object and also the
individual substreams. You can also close the substreams themselves. In most cases this only marks the substream as closed, so further I/O
on it fails. However, some streams may support "half-closed" states where one direction of the stream is actually shut down.
Namespace: GLib
Package: gio-2.0
Content:
Properties:
Creation methods:
Methods:
-
public void clear_pending ()
Clears the pending flag on stream.
-
public bool close (Cancellable? cancellable = null) throws IOError
Closes the stream, releasing resources related to it. This will also closes the individual input and
output streams, if they are not already closed.
-
public virtual async bool close_async (int io_priority = DEFAULT, Cancellable? cancellable = null) throws IOError
Requests an asynchronous close of the stream, releasing resources related to it. When the operation is
finished callback will be called. You can then call g_io_stream_close_finish to get the result of the
operation.
-
public virtual bool close_fn (Cancellable? cancellable = null) throws Error
-
public virtual weak InputStream get_input_stream ()
Gets the input stream for this object. This is used for reading.
-
public virtual weak OutputStream get_output_stream ()
Gets the output stream for this object. This is used for writing.
-
public bool has_pending ()
Checks if a stream has pending actions.
-
public bool is_closed ()
Checks if a stream is closed.
-
public bool set_pending () throws Error
Sets stream to have actions pending. If the pending flag is already set or stream
is closed, it will return false and set error.
-
public async bool splice_async (IOStream stream2, IOStreamSpliceFlags flags, int io_priority = DEFAULT, Cancellable? cancellable = null) throws Error
Asyncronously splice the output stream of stream1 to the input stream of stream2
, and splice the output stream of stream2 to the input stream of stream1.