Stream Types


There are two types of streams available: base and composable . Base streams are streams that work directly with a backing store such as a file. Composable streams , on the other hand, are streams that operate on top of other streams. Composable streams by their nature have constructors that accept a stream as a parameter, whereas base streams do not. Therefore, a composable stream relies on the base stream you provide as input. For example, you can have a stream that handles encryption and decryption of data. If you want to write encrypted data to a file, you can write to a composable encryption stream that must call a base stream that s capable of writing the data from the encryption stream to a file. You can layer as many composable streams as you want on top of one another until you reach a base stream.

Figure 2-2 shows a stream relationship diagram that describes how base streams and composable streams interact with one another. At the top of the diagram, you ll see stream readers and writers that are essentially classes specifically designed to read or write formatted data to a stream. Stream readers and writers are described later in the chapter, and you ll find that they make stream programming easier because they allow you to work with data using a friendlier format, such as strings. It s important to note that the readers and writers can interact with either composable streams or base streams to perform I/O. The composable stream box shows that a composable stream must interact with a base stream to perform I/O on a system resource. A composable stream can also interact with another composable stream. The dashed line between the composable and base stream boxes illustrate this interaction. The base stream box shows that base streams are the only interfaces that actually interact directly with system resources.


Figure 2-2: Stream relationship diagram



Network Programming for the Microsoft. NET Framework
Network Programming for the MicrosoftВ® .NET Framework (Pro-Developer)
ISBN: 073561959X
EAN: 2147483647
Year: 2003
Pages: 121

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net