No, I can not delete QTcpServer, because I must operate with other accepted connections.
I want only say to the next incomming connection, that they should wait because server is overloaded, maybe something like this:
void Server::incomingConnection(int socketId)
{
if( canAcceptConnection() )
addClient(socketId);
else {
socket->setSocketDescriptor(socketId);
socket->write("Server is overloaded, try again later...\r\n");
socket->close();
socket->deleteLater();
}
}
void Server::incomingConnection(int socketId)
{
if( canAcceptConnection() )
addClient(socketId);
else {
QTcpSocket *socket = new QTcpSocket(this);
socket->setSocketDescriptor(socketId);
socket->write("Server is overloaded, try again later...\r\n");
socket->close();
socket->deleteLater();
}
}
To copy to clipboard, switch view to plain text mode
that is a good idea?
Bookmarks