Using Communication Services with Sockets
The Communication Services Layer cannot use socket objects directly because
RWSocket is not derived from
RWPortal. The Communication Services Layer can use
RWSocketPortal, though, because it is derived from
RWPortal. In addition, if a portal is not available, a temporary portal can be used.
Example 14 writes the current date to a socket that is obtained from a legacy C application.
Example 14 – Using RWSocketPortal to write into a socket
void spewDate(SOCKET fd) //1
{
RWSocket sock(fd); //2
RWSocketPortal portal(sock,RWSocketPortal::Application); //3
RWPortalOStream strm(portal); //4
strm << RWDate() << endl; //5
} //6