Relationship to Other Modules
To this point, we have limited our discussion of the Essential Networking Module to its basic concepts: its definition, operation, and main abstractions. Our purpose was to make it as easy as possible to understand the module by isolating specific topics. However, the greater value of the Essential Networking Module is that it works seamlessly with the other SourcePro modules. Here we say a few words about how the Essential Networking Module functions with SourcePro Net and with the SourcePro product line in general.
Essential Networking and SourcePro Net
The Rogue Wave product SourcePro Net consists of three modules: Essential Networking, Internet Protocols and Secure Communication. The modules are divided into packages, and the Essential Networking Module contains one package, Networking.
Within SourcePro Net, the role of the Essential Networking Module is to provide the basic networking functionality that the other modules build on. For example, the Internet Protocols Module implements the HTTP, FTP, SMTP, and POP3 protocols using Essential Networking classes such as
RWSocket,
RWPortal, and
RWInetAddr. Most users of the Internet Protocols Module don't see
RWSocket or
RWPortal, but in many cases these classes supply the underlying functionality.
More visibly, the Secure Communication Module builds on the classes found in the Essential Networking Module to provide an object-oriented API for secure communication. Class
RWSecureSocket of the Secure Communication module has an API compatible with
RWSocket, and uses classes such as
RWSockAddrBase from the Essential Networking Module in its interface. The architecture of the Secure Communication Module is based on the architecture of the Essential Networking Module.
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.