Using Streams: 1.5 Using Streams: The Basics: Shutting Down a Stream

Up: GEOS SDK TechDocs | Up | Prev: 1.4 Reading Data from a Stream | Next: 1.6 Miscellaneous Functions
StreamClose()

Either the writer or the reader can instigate stream shutdown by calling StreamClose() . When one of the two calls this routine, the shut-down process is started; it will not be completed until the other calls the routine.

If the writer calls StreamClose() , it may specify that the data already in the buffer be flushed (immediately cleared), or that it linger . If you specify that the data should linger, the data will be preserved as long as the reader has the stream open. The reader can continue to read data normally until it runs out of data. The last read-operation will most likely return STREAM_SHORT_READ_WRITE; after that, all attempts to read data will generate the error STREAM_CLOSING. At that point, the reader should call StreamClose() . (If the data was flushed by the writer, the next read attempt will return STREAM_CLOSING.)

To shut down the stream, call the routine StreamClose() . This routine is passed the following arguments:

If you are using the Serial or Parallel drivers (described later in this chapter), you do not have to coordinate the closure of a stream.


Up: GEOS SDK TechDocs | Up | Prev: 1.4 Reading Data from a Stream | Next: 1.6 Miscellaneous Functions