Using rwSocketSelect
You can use the global function rwSocketSelect() to test attributes and wait for them to become true. Example 15 shows how to wait on two sockets at the same time.
Example 15 – Using the global function rwSocketSelect
// Somehow establish two connected sockets, s1 and s2
 
RWTValOrderedVector<RWSocketAttribute> waiton; //1
waiton.append(RWSocketAttribute(
s1,RWSocketAttribute::CANREAD)); //2
waiton.append(RWSocketAttribute(
s2,RWSocketAttribute::CANREAD));
RWTValOrderedVector<RWSocketAttribute> ready =
rwSocketSelect(waiton); //3
 
// Do something with the sockets that are ready
 
//1 Builds a vector of socket attributes to wait for. An Essential Tools Module ordered vector class represents the list of attributes.
//2 Adds the conditions to the list. In this case, the application is waiting for either s1 or s2 to be ready for reading.
//3 Waits for at least one condition to be true. The conditions are passed in as an RWTValOrderedVector<RWSocketAttribute>, a vector of socket attributes. If one of the conditions in waiton is already true, rwSocketSelect() returns immediately. You can pass an optional second argument to set a timeout in seconds. The function returns a list of conditions that are true.
NOTE: The Essential Networking Module page of the SourcePro API Reference Guide describes rwSocketSelect() in the Function Documentation section of that page.