Essential Networking and the SourcePro Product Line
In addition to providing basic functionality for SourcePro Net, the Essential Networking Module can be used with any module of the SourcePro product line. In particular, it builds on the basic classes of SourcePro Core, and exposes some of those classes through its public API. For example, the Essential Networking Module uses some of the classes of the Essential Tools Module for basic concepts such as strings and vectors. In the global function rwSocketSelect(), the Essential Networking Module uses class RWTValVector<T> to return collections of sockets. Several of the examples in this chapter use RWCString to represent strings, as in:
RWCString hostname = host.getName();
However, the most important thing to notice is that, because the Essential Networking Module integrates with the standard C++ iostreams, we can use any code or product that uses the standard C++ iostreams with the Essential Networking Module. For example, we could use the virtual streams from the Essential Tools Module to stream C++ objects over a socket in a platform-independent manner, as in the following example:
 
RWSocketPortal sp(RWInetAddr(1234, "www.roguewave.com")); //1
RWPortalOStream ostr(sp); //2
RWpostream pstr(ostr); //3
 
Customer c = ... ; //4
 
pstr << c; //5
On //1, we create an RWSocketPortal, and on //2 we obtain an RWPortalOStream for the write side of our socket. On //3 we create an RWpostream, the portable output stream provided by the Essential Tools Module, around the RWPortalOStream. (RWpostream allows objects to be sent over a stream in a portable, platform-independent manner.)
On //4 we obtain an imaginary Customer object, and on //5 we stream it over the network connection by simply using operator<<(). (Note that this would require our Customer class to be streamable with the Essential Tools virtual streams; for more information, see the Essential Tools Module User's Guide.)
The SourcePro Core XML Streams Module interacts with C++ iostreams, so anything that implements the standard C++ iostreams interface can be used with the XML Streams Module. The Essential Networking Module, through classes RWPortalIStream and RWPortalOStream implements this interface for network connections, making it possible for XML streams or any other technology based on iostreams to be used over the network.