Class

GioIOStream

since: 2.22

Description [src]

abstract class Gio.IOStream : GObject.Object
{
  /* No available fields */
}

GIOStream represents an object that has both read and write streams. Generally the two streams act as separate input and output streams, but they share some common resources and state. For instance, for seekable streams, both streams may use the same position.

Examples of GIOStream objects are GSocketConnection, which represents a two-way network connection; and GFileIOStream, which represents a file handle opened in read-write mode.

To do the actual reading and writing you need to get the substreams with g_io_stream_get_input_stream() and g_io_stream_get_output_stream().

The GIOStream object owns the input and the output streams, not the other way around, so keeping the substreams alive will not keep the GIOStream object alive. If the GIOStream object is freed it will be closed, thus closing the substreams, so even if the substreams stay alive they will always return G_IO_ERROR_CLOSED for all operations.

To close a stream use g_io_stream_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 but common state in the GIOStream may still be open. However, some streams may support ‘half-closed’ states where one direction of the stream is actually shut down.

Operations on GIOStreams cannot be started while another operation on the GIOStream or its substreams is in progress. Specifically, an application can read from the GInputStream and write to the GOutputStream simultaneously (either in separate threads, or as asynchronous operations in the same thread), but an application cannot start any GIOStream operation while there is a GIOStream, GInputStream or GOutputStream operation in progress, and an application can’t start any GInputStream or GOutputStream operation while there is a GIOStream operation in progress.

This is a product of individual stream operations being associated with a given GMainContext (the thread-default context at the time the operation was started), rather than entire streams being associated with a single GMainContext.

GIO may run operations on GIOStreams from other (worker) threads, and this may be exposed to application code in the behaviour of wrapper streams, such as GBufferedInputStream or GTlsConnection. With such wrapper APIs, application code may only run operations on the base (wrapped) stream when the wrapper stream is idle. Note that the semantics of such operations may not be well-defined due to the state the wrapper stream leaves the base stream in (though they are guaranteed not to crash).

Available since: 2.22

Ancestors

Functions

g_io_stream_splice_finish

Finishes an asynchronous io stream splice operation.

since: 2.28

Instance methods

g_io_stream_clear_pending

Clears the pending flag on stream.

since: 2.22

g_io_stream_close

Closes the stream, releasing resources related to it. This will also close the individual input and output streams, if they are not already closed.

since: 2.22

g_io_stream_close_async

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.

since: 2.22

g_io_stream_close_finish

Closes a stream.

since: 2.22

g_io_stream_get_input_stream

Gets the input stream for this object. This is used for reading.

since: 2.22

g_io_stream_get_output_stream

Gets the output stream for this object. This is used for writing.

since: 2.22

g_io_stream_has_pending

Checks if a stream has pending actions.

since: 2.22

g_io_stream_is_closed

Checks if a stream is closed.

since: 2.22

g_io_stream_set_pending

Sets stream to have actions pending. If the pending flag is already set or stream is closed, it will return FALSE and set error.

since: 2.22

g_io_stream_splice_async

Asynchronously 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.

since: 2.28

Methods inherited from GObject (43)

Please see GObject for a full list of methods.

Properties

Gio.IOStream:closed

Whether the stream is closed.

since: 2.22

Gio.IOStream:input-stream

The GInputStream to read from.

since: 2.22

Gio.IOStream:output-stream

The GOutputStream to write to.

since: 2.22

Signals

Signals inherited from GObject (1)
GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

Class structure

struct GioIOStreamClass {
  GObjectClass parent_class;
  GInputStream* (* get_input_stream) (
    GIOStream* stream
  );
  GOutputStream* (* get_output_stream) (
    GIOStream* stream
  );
  gboolean (* close_fn) (
    GIOStream* stream,
    GCancellable* cancellable,
    GError** error
  );
  void (* close_async) (
    GIOStream* stream,
    int io_priority,
    GCancellable* cancellable,
    GAsyncReadyCallback callback,
    gpointer user_data
  );
  gboolean (* close_finish) (
    GIOStream* stream,
    GAsyncResult* result,
    GError** error
  );
  void (* _g_reserved1) (
void
  );
  void (* _g_reserved2) (
void
  );
  void (* _g_reserved3) (
void
  );
  void (* _g_reserved4) (
void
  );
  void (* _g_reserved5) (
void
  );
  void (* _g_reserved6) (
void
  );
  void (* _g_reserved7) (
void
  );
  void (* _g_reserved8) (
void
  );
  void (* _g_reserved9) (
void
  );
  void (* _g_reserved10) (
void
  );
  
}

No description available.

Class members
parent_class: GObjectClass

No description available.

get_input_stream: GInputStream* (* get_input_stream) ( GIOStream* stream )

No description available.

get_output_stream: GOutputStream* (* get_output_stream) ( GIOStream* stream )

No description available.

close_fn: gboolean (* close_fn) ( GIOStream* stream, GCancellable* cancellable, GError** error )

No description available.

close_async: void (* close_async) ( GIOStream* stream, int io_priority, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer user_data )

No description available.

close_finish: gboolean (* close_finish) ( GIOStream* stream, GAsyncResult* result, GError** error )

No description available.

_g_reserved1: void (* _g_reserved1) ( void )

No description available.

_g_reserved2: void (* _g_reserved2) ( void )

No description available.

_g_reserved3: void (* _g_reserved3) ( void )

No description available.

_g_reserved4: void (* _g_reserved4) ( void )

No description available.

_g_reserved5: void (* _g_reserved5) ( void )

No description available.

_g_reserved6: void (* _g_reserved6) ( void )

No description available.

_g_reserved7: void (* _g_reserved7) ( void )

No description available.

_g_reserved8: void (* _g_reserved8) ( void )

No description available.

_g_reserved9: void (* _g_reserved9) ( void )

No description available.

_g_reserved10: void (* _g_reserved10) ( void )

No description available.

Virtual methods

Gio.IOStreamClass.close_async

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.

since: 2.22

Gio.IOStreamClass.close_finish

Closes a stream.

since: 2.22

Gio.IOStreamClass.close_fn
No description available.

Gio.IOStreamClass.get_input_stream

Gets the input stream for this object. This is used for reading.

since: 2.22

Gio.IOStreamClass.get_output_stream

Gets the output stream for this object. This is used for writing.

since: 2.22