wasm: fix QTcpSocket error code when url doesn't exist

::connect on wasm seems to be returning 0 in the instance that the
server url does not exist.
So we ignore that and look at errno, which returns ENOENT
which makes no sense here.

Fixes: QTBUG-132191
Change-Id: I2ff6642dd836324e1af6c288c53880de028ce158
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
(cherry picked from commit 1a8c8ffb0c45644c05ea1474df48bfdeea563524)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Reviewed-by: Lorn Potter <lorn.potter@qt.io>
This commit is contained in:
Lorn Potter 2024-12-16 14:38:44 +10:00 committed by Qt Cherry-pick Bot
parent 304e4e5cc4
commit 7cd587aff1
2 changed files with 6 additions and 0 deletions

View File

@ -401,6 +401,7 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &addr, quint16
break;
case ECONNREFUSED:
case EINVAL:
case ENOENT:
setError(QAbstractSocket::ConnectionRefusedError, ConnectionRefusedErrorString);
socketState = QAbstractSocket::UnconnectedState;
break;

View File

@ -109,6 +109,11 @@ static inline int qt_safe_connect(int sockfd, const struct sockaddr *addr, QT_SO
int ret;
// Solaris e.g. expects a non-const 2nd parameter
QT_EINTR_LOOP(ret, QT_SOCKET_CONNECT(sockfd, const_cast<struct sockaddr *>(addr), addrlen));
#ifdef Q_OS_WASM
// ::connect on wasm returns 0 when it shouldn't so use errno instead
if (errno != 0)
ret = -1;
#endif
return ret;
}
#undef QT_SOCKET_CONNECT