Hey, i have this code, and i don't know why timeout don't work...
void Server::update() /// stupid sending packets...
{
for( std::vector<Client*>::iterator it = clients.begin(); it!= clients.end(); ++it )
{
Client &client = **it;
if (Selector.wait(sf::milliseconds(500)))
{
if(Selector.isReady(client.Socket))
{
if ( client.Recv(50) )
{
...
}
else /// This line never do...
SendMapInfo();
}
}
}
}
bool Client::Recv(float t)
{
send.clear();
recv.clear();
sf::SocketSelector selector;
selector.add(Socket);
if( selector.wait(sf::milliseconds(t)))
{
if(Socket.receive(recv)== sf::Socket::Done)
{
recv >> family >> action;
return true;
}
else return false;
}
else return false;
}