## gskstreamconnection

gskstreamconnection — Connection between the input of one stream and the output of another.

## Synopsis

                        GskStreamConnection;
    GskStreamConnection * gsk_stream_connection_new         (GskStream *input_stream,
                                                             GskStream *output_stream,
                                                             GError **error);
    guint               gsk_stream_connection_get_atomic_read_size
                                                            (GskStreamConnection *connection);
    void                gsk_stream_connection_set_atomic_read_size
                                                            (GskStreamConnection *connection,
                                                             guint atomic_read_size);
    guint               gsk_stream_connection_get_max_buffered
                                                            (GskStreamConnection *connection);
    void                gsk_stream_connection_set_max_buffered
                                                            (GskStreamConnection *connection,
                                                             guint max_buffered);
    void                gsk_stream_connection_shutdown      (GskStreamConnection *connection);
    void                gsk_stream_connection_detach        (GskStreamConnection *connection);

## Description

This object allows you to configure the connection between two streams more precisely than `gsk_stream_attach()`.

## Details

### GskStreamConnection

    typedef struct {
      GObject      object;

      /* The stream to read from. */
      GskStream *read_side;

      /* The stream to write to. */
      GskStream *write_side;

      /* Whether we are blocking the read-side because the buffer is 0 length. */
      guint blocking_write_side : 1;

      /* Whether we are blocking the write-side because the buffer is too long. */
      guint blocking_read_side : 1;

      /* Whether to use gsk_stream_read_buffer() on the read-side.
         This is TRUE by default, even though it can cause
         both max_buffered and atomic_read_size to be violated. */
      guint use_read_buffer : 1;

      /* Data which is to be transferred from read_side to write_side,
         which hasn't been processed on the write side. */
      GskBuffer buffer;

      /* The maximum number of bytes to store in buffer. */
      guint max_buffered;

      /* The maximum number of bytes to read atomically from the input stream. */
      guint atomic_read_size;
    } GskStreamConnection;

An opaque object representing the connection between the input of one stream and the output of another.

### gsk_stream_connection_new ()

    GskStreamConnection * gsk_stream_connection_new         (GskStream *input_stream,
                                                             GskStream *output_stream,
                                                             GError **error);

Attach the read end of `input_stream` to the write end of `output_stream`, returning an error if anything goes wrong.

`input_stream` : | the input stream whose read-end will be trapped.
`output_stream` : | the output stream whose write-end will be trapped.
`error` : | optional error return location.
Returns : | a reference at the connection. You should use eventually call `g_object_unref()` on the connection.

### gsk_stream_connection_get_atomic_read_size ()

    guint               gsk_stream_connection_get_atomic_read_size
                                                            (GskStreamConnection *connection);

Set the number of bytes to read atomically from an underlying source.

`connection` : | the connection to query.
Returns : | the size to read at a time.

### gsk_stream_connection_set_atomic_read_size ()

    void                gsk_stream_connection_set_atomic_read_size
                                                            (GskStreamConnection *connection,
                                                             guint atomic_read_size);

Set the number of bytes to read atomically from an underlying source. This is only used if the input stream has no read_buffer method.

`connection` : | the connection to affect.
`atomic_read_size` : | the size to read at a time.

### gsk_stream_connection_get_max_buffered ()

    guint               gsk_stream_connection_get_max_buffered
                                                            (GskStreamConnection *connection);

Get the maximum number of bytes of data to buffer between the input and output ends of the connection.

The actual number of bytes of data can be found with `gsk_stream_connection_get_cur_buffered()`.

`connection` : | the connection to query.
Returns : | the maximum number of bytes.

### gsk_stream_connection_set_max_buffered ()

    void                gsk_stream_connection_set_max_buffered
                                                            (GskStreamConnection *connection,
                                                             guint max_buffered);

Adjust the maximum amount of memory buffer to use between these streams.

Sometimes, we will buffer more data, either because set_max_buffer was run to make the amount allowed smaller than the amount currently buffered, or because there was a buffer-to-buffer transfer (which are allowed to be large).

`connection` : | the connection to affect.
`max_buffered` : | maximum of data to hold from the input stream for the output stream. After this much data has built up, we will no longer read from the input stream.

### gsk_stream_connection_shutdown ()

    void                gsk_stream_connection_shutdown      (GskStreamConnection *connection);

Shut down both ends of a connection.

`connection` : | the connection to shut down.

### gsk_stream_connection_detach ()

    void                gsk_stream_connection_detach        (GskStreamConnection *connection);

Disconnects the input/output pair of a connection. Data held in the buffer will be lost.

`connection` : | the connection to detach.

## See Also

`gsk_stream_attach()`.