Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: receive timeout don't work  (Read 1971 times)

0 Members and 1 Guest are viewing this topic.

Soul

  • Newbie
  • *
  • Posts: 44
    • View Profile
receive timeout don't work
« on: May 29, 2014, 05:45:48 pm »
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;
}
 
« Last Edit: May 29, 2014, 05:47:25 pm by Soul »