In the Reference (http://"http://www.sfml-dev.org/documentation/2.1/classsf_1_1SocketSelector.php#a9cfda5475f17925e65889394d70af702") I find:
bool sf::SocketSelector::wait (Time timeout = Time::Zero)
This function returns as soon as at least one socket has some data available to be received. To know which sockets are ready, use the isReady function.
In the Tutorial (http://"http://www.sfml-dev.org/documentation/2.1/classsf_1_1SocketSelector.php") I read(short):
// The listener socket is not ready, test all other sockets (the clients)
for (std::list<sf::TcpSocket*>::iterator it = clients.begin(); it != clients.end(); ++it)
{
if (selector.isReady(client))
{
//Receiving data
}
}
This example generates complexity N. I would lower it to approx. N/2 by breaking the loop after finding the ready client. But I am afraid that there would be more than one client ready.
My problem:
If you can imagine any example when there is more than one client ready, please explain it.
If there is anything else important to know about why I should check every client after the first found as "Ready", tell me.
Thank you.
I haven't find the answer on google, nor in any present topic.
1. Can a client become "Ready" after wait() returns true and before another wait() is called?
2. At which point a client becomes "Ready"?
3. Is selector.isReady(client) equal to client.receive(packet) or getting "Ready" takes place before receiving?
4. Would:
client.receive(packet);
be equal to:
client.receive(packet);
packet.clear();
client.receive(packet);