Each instance of a stream has an abstract data pointer that can hold underlying resource handle(s) and other stateful data required by your stream.

Lets see how to write a very simple file based stream, using POSIX IO.

1: struct my_stream_data {
2:         int filedes;
3: }
When we create our stream, we will store a pointer to the above structure in the abstract field of the stream structure.

We can now move on and write the core operations for our stream...