server->setMaxPendingConnections(2);
void Widget::OnClientConnected(){ players++; QMessageBox::information(this,"connection!","client connected!"); switch(players) { case 1: socket1 = server->nextPendingConnection(); connect(socket1, SIGNAL(readyRead()), this, SLOT(OnReceiveData())); connect(socket1, SIGNAL(disconnected()), this, SLOT(OnClientDisconnected())); this->listWidget->addItem(socket1->peerAddress().toString()+":"+QString::number(socket1->peerPort()) ); break; case 2: socket2 = server->nextPendingConnection(); connect(socket2, SIGNAL(readyRead()), this, SLOT(OnReceiveData())); connect(socket2, SIGNAL(disconnected()), this, SLOT(OnClientDisconnected())); this->listWidget->addItem(socket2->peerAddress().toString()+":"+QString::number(socket2->peerPort()) ); break; default:// server->nextPendingConnection()->abort(); // с этим вроде работает, но прочему maxPendingConnection не ограничивает не пойму players--; QMessageBox::information(this,"disconection!","client disconected because already 2 players!"); }}