Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Networking Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

8.3 Using the Networking Package in Global Objects

The technique described in Section 8.2 does not work if you use the Networking package in global objects. For example, if the program contains a global connection to a server, as shown below:

then the constructor for this global object is executed before the constructor for the RWWinSockInfo in main() or WinMain(). One solution is to add a static global RWWinSockInfo object before the definition of globalPortal, as shown below:

The RWWinSockInfo object defined in line //1 is guaranteed to be constructed before the portal is defined in the next line. It is not destroyed until after the portal is destroyed.


The RWWinSockInfo object is not guaranteed to be constructed first if the globals are in different modules.

Your application can nest RWWinSockInfo objects. The first call to the constructor initializes the Winsock DLL, and the last call to the destructor cleans up the Winsock DLL.



Previous fileTop of DocumentContentsIndex pageNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.