Using Channel-specific Portal Classes
RWPortal cannot handle the details of communication, such as making the connection to the server, because the parameters and steps involved in making the connection are different for each channel type. The Networking package solves this problem by using channel-specific portal classes, such as
RWSocketPortal. These classes inherit from
RWPortal, and add constructors and operations specific to their channel type. For example,
RWSocketPortal adds constructors that accept socket addresses, and it adds socket-specific functions for operations like returning the underlying
RWSocket object or connecting to a user-defined Internet server.
The channel-specific portal classes do not change the behavior of
RWPortal member functions that use inheritance—
RWPortal has no virtual member functions. For this reason, you can assign a channel-specific portal to an
RWPortal without changing the semantics of the portal, as shown in
Example 4, Assigning a channel-specific portal.Example 4 – Assigning a channel-specific portal
RWSocketPortal makeConnection()
{
RWSocketPortal sp( RWInetAddr(3010,"net.roguewave.com") ); //1
return sp;
}
main()
{
RWWinSockInfo info;
RWPortal portal = makeConnection(); //2
.
.
.
}