mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 01:17:14 +02:00
Merge pull request #5632 from birarda/master
force the HTTPManager to listen on IPv4
This commit is contained in:
commit
90483e7c97
2 changed files with 16 additions and 4 deletions
|
@ -30,6 +30,7 @@ HTTPManager::HTTPManager(quint16 port, const QString& documentRoot, HTTPRequestH
|
||||||
_port(port)
|
_port(port)
|
||||||
{
|
{
|
||||||
bindSocket();
|
bindSocket();
|
||||||
|
|
||||||
_isListeningTimer = new QTimer(this);
|
_isListeningTimer = new QTimer(this);
|
||||||
connect(_isListeningTimer, &QTimer::timeout, this, &HTTPManager::isTcpServerListening);
|
connect(_isListeningTimer, &QTimer::timeout, this, &HTTPManager::isTcpServerListening);
|
||||||
_isListeningTimer->start(SOCKET_CHECK_INTERVAL_IN_MS);
|
_isListeningTimer->start(SOCKET_CHECK_INTERVAL_IN_MS);
|
||||||
|
@ -171,9 +172,19 @@ void HTTPManager::isTcpServerListening() {
|
||||||
|
|
||||||
bool HTTPManager::bindSocket() {
|
bool HTTPManager::bindSocket() {
|
||||||
qCDebug(embeddedwebserver) << "Attempting to bind TCP socket on port " << QString::number(_port);
|
qCDebug(embeddedwebserver) << "Attempting to bind TCP socket on port " << QString::number(_port);
|
||||||
if (!listen(QHostAddress::Any, _port)) {
|
|
||||||
|
if (listen(QHostAddress::AnyIPv4, _port)) {
|
||||||
|
qCDebug(embeddedwebserver) << "TCP socket is listening on" << serverAddress() << "and port" << serverPort();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
qCritical() << "Failed to open HTTP server socket:" << errorString() << " can't continue";
|
qCritical() << "Failed to open HTTP server socket:" << errorString() << " can't continue";
|
||||||
QCoreApplication::exit(SOCKET_ERROR_EXIT_CODE);
|
QMetaObject::invokeMethod(this, "queuedExit", Qt::QueuedConnection);
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
void HTTPManager::queuedExit() {
|
||||||
|
QCoreApplication::exit(SOCKET_ERROR_EXIT_CODE);
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ public:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void isTcpServerListening();
|
void isTcpServerListening();
|
||||||
|
void queuedExit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool bindSocket();
|
bool bindSocket();
|
||||||
|
|
Loading…
Reference in a new issue