Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Networking Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

5.4 Using Virtual Streams

The Networking package iostream classes enable you to use any of the virtual streams classes in Rogue Wave's Essential Tools Module. The virtual streams classes handle the mechanics of reading and writing data into the various streams and formats, but your application must create helper functions for every class that will be transmitted over a stream. These helper functions read and write the instance variables of a class. For more information, see the SourcePro C++ API Reference Guide.

5.4.1 Constructing a Portable ASCII Virtual Stream for Output

Example 7 shows how to construct a portable ASCII virtual stream for output using an RWPortalStreambuf.

Example 7: Constructing a portable ASCII virtual stream for output

The streambuf object buf must remain in scope as long as the output stream is being used because the output stream keeps a pointer to the streambuf. If buf goes out of scope, the pointer in the output stream becomes invalid, and when the stream attempts to write bytes, the application will fail.

5.4.2 Constructing a Binary Virtual Stream for Input from a Portal

Example 8 is similar to Example 7, except that it sets up a binary virtual stream for input from a portal.

Example 8: Constructing a binary virtual stream for input from a portal

5.4.3 Creating Chains of Objects

When creating an instance of a Rogue Wave virtual stream, such as an RWpostream, you will usually use a low-level construct, such as an RWSocket. In many cases, you will need to build some intermediate objects before creating the virtual stream. For example, you might create an RWPortal, then an RWPortalStreambuf, and then an RWpostream.



Previous fileTop of DocumentContentsIndex pageNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.