Afer asking, I'd see the reason: If I remove "else", the loop will try to read data from "listener" socket. I could code some "if" to don't read from "listener". But could be another way; "listener" non-blocking. The problen is that "connect()" don't return a new socket (as the usual in such APIs) and I must privide it.
listener.setBlocking(false);
sf::TcpSocket *newClient = new sf::TcpSocket();
while(1)
{
if (listener.accept(*newClient) == sf::Socket::Done)
{
// Add new client.
newClient = new sf::tcpSocket(); // Preparing new socket for next client.
}
if( selector.wait(1) )// One Millisecond wait.
{
// Check clients sockets to receive their data.
}
}
What do you think?
Maybe this changes doesn't care at all xD
Silderán.