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 Essential Tools Module Reference Guide.
Example 7 shows how to construct a portable ASCII virtual stream for output using an RWPortalStreambuf.
RWPortalStreambuf buf(portal); RWpostream ostrm(&buf);
The std::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.
Example 8 is similar to Example 7, except that it sets up a binary virtual stream for input from a portal.
RWPortalStreambuf buf(portal); RWbistream istrm(&buf);
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.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.