<!-- ##### SECTION Title ##### -->
Binary Input/Output Stream Base

<!-- ##### SECTION Short_Description ##### -->
A byte stream.  This has methods to read and write data,
and it inherits read/write notification from #GskStream.

<!-- ##### SECTION Long_Description ##### -->
<para>
This encapsulates anything which reads bytes in or writes bytes out.
Examples are a unix socket or a http-protocol implementation.
</para>
<para>
It supports all the richness of #GskIO's read/write notification
system, along with read and write methods.
In particular, (1) you can trap and block read/write separately on the stream.
(2) the read/write ends of the stream can be shutdown separately.
(3) in general, you may not be able to read/write immediately,
but instead may have to trap the appropriate end to know when you can
read or write.  (4) you may be able to only write or read a partial buffer.
</para>
<para>
By checking certain flags below, you can assume that the data will never be partial,
or that the stream will never block.
</para>

<!-- ##### SECTION See_Also ##### -->
<para>
#GskIO
</para>

<!-- ##### SECTION Stability_Level ##### -->


<!-- ##### STRUCT GskStreamClass ##### -->
<para>
Functions which may be overridden by derived classes to provide
input and output methods.
</para>

@base_class: 
@raw_read: function to read raw binary data into a contiguous buffer.
This function may not block, but it can return any number of bytes
without an error code (even returning 0 does NOT imply end-of-file),
or it can return a GError when things go wrong.
@raw_write: 
This function may not block, but it can return any number of bytes
without an error code (if it returns 0, it merely means that it does not have
space or time for more outgoing data; it is not necessarily an error).
Or it can return a GError when things go wrong.
@raw_read_buffer: 
Optional function to read from a stream and transfer it into a buffer,
without blocking.
This function is provided as an optimization.
@raw_write_buffer: 
Optional function to write to a stream from a buffer,
without blocking.
This function is provided as an optimization.

<!-- ##### STRUCT GskStream ##### -->
<para>
An input and/or output stream of raw bytes.
This has input and output triggers, inherited from #GskIO
as well as methods to read and write raw bytes.
</para>


<!-- ##### FUNCTION gsk_stream_read ##### -->
<para>

</para>

@stream: 
@buffer: 
@buffer_length: 
@error: 
@Returns: 


<!-- ##### FUNCTION gsk_stream_write ##### -->
<para>

</para>

@stream: 
@buffer: 
@buffer_length: 
@error: 
@Returns: 


<!-- ##### FUNCTION gsk_stream_read_buffer ##### -->
<para>

</para>

@stream: 
@buffer: 
@error: 
@Returns: 


<!-- ##### FUNCTION gsk_stream_write_buffer ##### -->
<para>

</para>

@stream: 
@buffer: 
@error: 
@Returns: 


<!-- ##### FUNCTION gsk_stream_attach ##### -->
<para>

</para>

@input_stream: 
@output_stream: 
@error: 
@Returns: 


<!-- ##### FUNCTION gsk_stream_attach_pair ##### -->
<para>

</para>

@stream_a: 
@stream_b: 
@error: 
@Returns: 


<!-- ##### MACRO gsk_stream_get_is_connecting ##### -->
<para>
Test whether the stream is connecting.
</para>

@stream: the stream to test.


<!-- ##### MACRO gsk_stream_get_is_readable ##### -->
<para>
Test whether the stream is potentially readable.
(There may not be any data available at the moment, however.)
</para>

@stream: the stream to test.


<!-- ##### MACRO gsk_stream_get_is_writable ##### -->
<para>
Test whether the stream is potentially writable.
(you may not be able to write at the moment, however.)
</para>

@stream: the stream to test.


<!-- ##### MACRO gsk_stream_get_never_blocks_write ##### -->
<para>
Return if the #GskStream will never block to write data.  It will always allow
some data to be written, until it is full and will allow no more ever.
</para>

@stream: the stream to test.


<!-- ##### MACRO gsk_stream_get_never_blocks_read ##### -->
<para>
Return if the #GskStream will never block to read data.  It will always return
some data, until it is empty and will never return any more.
</para>

@stream: the stream to test.


<!-- ##### MACRO gsk_stream_get_idle_notify_write ##### -->
<para>
Return whether the write-hook is in idle-notify mode.
That means it will be triggered continually,
as long as there is a unblocked hook watching it.
</para>

@stream: the stream to test.


<!-- ##### MACRO gsk_stream_get_idle_notify_read ##### -->
<para>
Return whether the read-hook is in idle-notify mode.
That means it will be triggered continually,
as long as there is a unblocked hook watching it.
</para>

@stream: the stream to test.


<!-- ##### MACRO gsk_stream_get_is_open ##### -->
<para>
Return whether the #GskStream is open.  A #GskStream should be open if
you want to use it.
</para>

@stream: the stream to test.


<!-- ##### MACRO gsk_stream_get_never_partial_reads ##### -->
<para>
Return whether the #GskStream is never allowed to return a partial buffer.
</para>

@stream: the stream to test.


<!-- ##### MACRO gsk_stream_get_never_partial_writes ##### -->
<para>
Return whether the #GskStream is never allowed to write a partial buffer.
</para>

@stream: the stream to test.


<!-- ##### MACRO gsk_stream_mark_is_connecting ##### -->
<para>
Set the #GskStream's is_connecting flag.  This should only be called
by the implementations of derived classes.  By default,
GskStream is not in the connecting state.
</para>

@stream: the #GskStream to affect.


<!-- ##### MACRO gsk_stream_mark_is_readable ##### -->
<para>
Set whether the #GskStream is_readable.  This should only be called by
the implementations of derived classes.
</para>

@stream: the #GskStream to affect.


<!-- ##### MACRO gsk_stream_mark_is_writable ##### -->
<para>
Set whether the #GskStream is_writable.  This should only be called by
the implementations of derived classes.
</para>

@stream: the #GskStream to affect.


<!-- ##### MACRO gsk_stream_mark_never_blocks_write ##### -->
<para>
Indicate that writing to the #GskStream never will block.
Once this flag is set it cannot be cleared.
This should only be used by implementations of derived classes.
</para>

@stream: the #GskStream to affect.


<!-- ##### MACRO gsk_stream_mark_never_blocks_read ##### -->
<para>
Indicate that reading to the #GskStream never will block.
Once this flag is set it cannot be cleared.
This should only be used by implementations of derived classes.
</para>

@stream: the #GskStream to affect.


<!-- ##### MACRO gsk_stream_mark_idle_notify_write ##### -->
<para>
Tell the GskStream system to continually trigger a user's write hook,
if any, assuming it is not blocked.
This should only be used by implementations of derived classes.
</para>

@stream: the #GskStream to affect.


<!-- ##### MACRO gsk_stream_mark_idle_notify_read ##### -->
<para>
Tell the GskStream system to continually trigger a user's read hook,
if any, assuming it is not blocked.
This should only be used by implementations of derived classes.
</para>

@stream: the #GskStream to affect.


<!-- ##### MACRO gsk_stream_mark_is_open ##### -->
<para>
Indicate that a #GskStream is open.
This should only be used by implementations of derived classes.
</para>

@stream: the #GskStream to affect.


<!-- ##### MACRO gsk_stream_mark_never_partial_reads ##### -->
<para>
Indicate that the gsk_stream_read()
will always read a whole buffer of data.
</para>

@stream: the #GskStream to affect.


<!-- ##### MACRO gsk_stream_mark_never_partial_writes ##### -->
<para>
Indicate that the gsk_stream_write() and gsk_stream_write_buffer()
will always finish completely, or give an error.
</para>

@stream: the #GskStream to affect.


<!-- ##### MACRO gsk_stream_clear_is_readable ##### -->
<para>
Indicate that a #GskStream is no longer readable.
In most classes, this condition is permanent.
This should only be used by implementations of derived classes.
</para>

@stream: the #GskStream to affect.


<!-- ##### MACRO gsk_stream_clear_is_writable ##### -->
<para>
Indicate that a #GskStream is no longer writable.
In most classes, this condition is permanent.
This should only be used by implementations of derived classes.
</para>

@stream: the #GskStream to affect.


<!-- ##### MACRO gsk_stream_clear_is_open ##### -->
<para>
Indicate that the #GskStream is closed.
</para>

@stream: the #GskStream to affect.


<!-- ##### MACRO gsk_stream_clear_idle_notify_write ##### -->
<para>
Stop continually triggering the user's write hook.
(This undoes gsk_stream_mark_idle_notify_write())
</para>

@stream: the #GskStream to affect.


<!-- ##### MACRO gsk_stream_clear_idle_notify_read ##### -->
<para>
Stop continually triggering the user's read hook.
(This undoes gsk_stream_mark_idle_notify_read())
</para>

@stream: the #GskStream to affect.


<!-- ##### MACRO gsk_stream_clear_never_partial_reads ##### -->
<para>
Indicate that the #GskStream may exhibit partial reads.
</para>

@stream: the #GskStream to affect.


<!-- ##### MACRO gsk_stream_clear_never_partial_writes ##### -->
<para>
Indicate that the #GskStream may exhibit partial writes.
</para>

@stream: the #GskStream to affect.


<!-- ##### MACRO gsk_stream_trap_readable ##### -->
<para>
Trap the read end of a stream.  See gsk_io_trap_readable().
</para>



<!-- ##### MACRO gsk_stream_trap_writable ##### -->
<para>
Trap the write end of a stream.  See gsk_io_trap_writable().
</para>



<!-- ##### MACRO gsk_stream_untrap_readable ##### -->
<para>
Untrap the read end of a stream.  See gsk_io_untrap_readable().
</para>



<!-- ##### MACRO gsk_stream_untrap_writable ##### -->
<para>
Untrap the write end of a stream.  See gsk_io_untrap_writable().
</para>



