mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Try to listen even if the default port is no available.
This commit is contained in:
parent
ed130010e6
commit
a8932463f7
@ -39,9 +39,19 @@ void HttpListener::listen()
|
||||
QString host = settings->value("host").toString();
|
||||
int port=settings->value("port").toInt();
|
||||
QTcpServer::listen(host.isEmpty() ? QHostAddress::Any : QHostAddress(host), port);
|
||||
|
||||
//YACReader---------------------------------------------
|
||||
//try to listen even if the default port is no available
|
||||
int i = 0;
|
||||
while (!isListening() && i < 1000) {
|
||||
listen(QHostAddress::Any, (rand() % 45535)+20000);
|
||||
i++;
|
||||
}
|
||||
//------------------------------------------------------
|
||||
|
||||
if (!isListening())
|
||||
{
|
||||
qCritical("HttpListener: Cannot bind on port %i: %s",port,qPrintable(errorString()));
|
||||
qDebug("HttpListener: Cannot bind on port %i: %s",port,qPrintable(errorString()));
|
||||
}
|
||||
else {
|
||||
qDebug("HttpListener: Listening on port %i",port);
|
||||
|
Loading…
Reference in New Issue
Block a user