mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -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();
|
QString host = settings->value("host").toString();
|
||||||
int port=settings->value("port").toInt();
|
int port=settings->value("port").toInt();
|
||||||
QTcpServer::listen(host.isEmpty() ? QHostAddress::Any : QHostAddress(host), port);
|
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())
|
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 {
|
else {
|
||||||
qDebug("HttpListener: Listening on port %i",port);
|
qDebug("HttpListener: Listening on port %i",port);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user