i don't know why but Client can't connect to the server when i use selector...
Server
void Server::Init( int Port )
{
Listener.listen( Port );
std::cout << "***************** Game Test Server beta version 0.01 *****************" << std::endl;
}
void Server::Select()
{
if( Selector.wait() )
{
if( Selector.isReady( Listener ) )
{
Client *client = new Client;
if ( Listener.accept( client->Socket ) == sf::Socket::Done )
{
clients.push_back( client );
Selector.add( client->Socket );
std::cout << "Client connected: " << client->Socket.getRemoteAddress() << std::endl;
}
}
}
}
Client
void Client::Connect( const char *IP, int port )
{
Server.setBlocking( false );
if( Server.connect( IP, port) == sf::TcpSocket::Status::Done )
{
std::cout << "Connected with server: " << IP << std::endl;
Connected = true;
}
else if( Server.connect( IP, port ) == sf::TcpSocket::Status::Error )
{
std::cout << "Can't connect with server: " << IP << std::endl;
Connected = false;
}
}
when i remove selector client can connect but function shout Cant' connect with...
it's so fuckin strange...