Adding a Maximum Wait to Requests
Unexpected network traffic or network problems can cause your application to wait. To plan for these situations, the HTTP package classes include maxwait parameters.
The connect(), submit(), and getReply() member functions in RWHttpClient include an optional maxwait parameter, which is the maximum number of milliseconds that the RWHttpClient and related classes wait for data to become available from the server. Example 18 shows how to use maxwait.
Example 18 – Adding a maximum wait to requests
RWHttpClient client = RWHttpSocketClient::make();
 
client.connect("www.perforce.com", 80, 2000); // 1
//1 Issues a connection request to the server www.perforce.com:80 with a maximum wait of 2 seconds (2000 milliseconds).
RWHttpAgent also enables you to specify a timeout period, but it applies to all requests executed by a given RWHttpAgent object.
 
RWHttpAgent agent;
agent.setNetworkMaxwait(2000);
All requests executed through agent have a maximum timeout period of 2000.
NOTE: Specifying a timeout period does not guarantee that the given member functions will return within the time specified. A maxwait parameter throws an exception only if data is not received from the server within the maxwait period. As long as any data is being received from the server within the maxwait period, exceptions are not thrown.