Chapter 2: Managed IO: Streams, Readers, and Writers


Overview

The Microsoft Windows .NET Framework offers a unified way to access operating system resources such as files, memory, and network resources through the stream I/O pattern. Streams provide a common way to perform I/O operations regardless of the operating system resource. In general, streams allow you to read and write data sequentially to a container (which we call a backing store ) as if the data is a continuous sequence of bytes where the first byte that s written becomes the first byte to be read, and so on. The container is called a backing store because it will typically hold or store the data that s written to the stream. Figure 2-1 describes a stream as a sheet of paper where the paper represents a backing store that can hold letters of the alphabet. A supplier or writer can write the letters of the alphabet sequentially on the paper. A consumer or reader can eventually read the alphabetic characters from the paper in the order in which they were originally written.

click to expand
Figure 2-1: The stream I/O process

In this chapter, you ll discover how to perform I/O on files, memory, and networks using stream classes in the .NET Framework. We ll start out describing the Stream class that s inherited by several classes that allow you to perform I/O in a common way across different operating system resources. We ll focus mostly on performing I/O on files and network resources because this is a network programming book. Once we have described the core stream classes, we ll talk about other stream classes that interact with the core stream classes. Finally, we ll introduce stream readers and writers that allow you to read and write formatted text and binary data types to streams.




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