Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

3.4 Transferring Data Over a Socket

Let's suppose you want to pass information between C++ applications running on two hosts connected by TCP. The mechanism of choice would be a socket. Figure 1 demonstrates a chain of objects you could build in order to use virtual streams for this purpose.

Figure 1 -- Using virtual streams to communicate over a socket

From an RWSocket, you can create an RWSocketPortal instance. With this portal, you can create an RWPortalIStream. With this istream, you can create an instance of an RWvistream subclass. In this example, we create an endian input stream.

Note that you cannot read an object from an input stream unless the object was written to its matching output stream. For instance, you cannot write to a vostream, then have another application read the object from a pistream. Also note that, unless data_ is an instance of a Rogue Wave class, you must create helper functions to work with virtual streams. Most Rogue Wave classes include helper functions for virtual streams. The network/distcltn and network/server directories contain excellent examples of creating streams from RWSocketPortal instances.


Previous fileTop of DocumentContentsIndexNext file

©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.