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

6.4 Using Generic Socket Addresses

RWSockAddr represents any address family. It is a concrete class that can be instantiated directly and used as member data in objects. You can use RWSockAddr when you do not know the address family until run time.


The Networking package has one family of addresses, RWInetAddr. However, if you follow the guidelines in this section, your application will work with any family of addresses.

6.4.1 Constructing Generic Addresses

You can build an RWSockAddr in two ways:

6.4.2 Understanding How RWSockAddr Is Implemented

The RWSockAddr keeps a reference-counted pointer to the real address, which is an object on the heap of some type derived from RWSockAddrBase. The RWSockAddr acts as a proxy for the heap object. When you call member functions on the RWSockAddr, it forwards the calls to the object on the heap, which actually does the work.

Figure 9 shows the objects that are created by the following code.

Figure 9: Objects created by the RWSockAddr example

As the proxy objects go out of scope, the reference count is decremented. When no more objects refer to the object anRWInetAddr, it is automatically deleted.



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.