Controlling Network Access
The socket address classes use the virtual function RWSockAddrBase::prepare() to access the network. This function enables you to explicitly control when use of an address object might cause the thread of control to block. By calling prepare() right after an address is constructed, you guarantee that any future use of that address will not cause your application to block.
The code shown below retrieves the host name associated with an Internet address.
RWInetAddr addr(80,"198.68.9.3");
RWCString name = addr.host().name(); //1
The call in line //1 may require a network access to look up the name. This can cause the thread of control to block while the network access occurs.
To avoid a block, you can write the code like this:
RWInetAddr addr(80,"198.68.9.3");
addr.prepare(); //1
RWCString name = addr.host().name(); //2
The code on line //2 no longer uses the network and will not block because the call to prepare() on line //1 has already retrieved the information for that address.