Details
-
Bug
-
Resolution: Done
-
P2: Important
-
6.0
-
None
-
93ff67a3fce7ebe477085541217eef4000e310be (qt-labs/qthttpserver/master)
Description
I don't think QAbstractHttpServer::listen() returning the port or -1 on failure is a good idea. QTcpServer sets precedent and QWebSockerServer, QSctpServer follow, where listen() is a bool:
bool QTcpServer::listen(const QHostAddress &address = QHostAddress::Any, quint16 port = 0);
quint16 QTcpServer::serverPort() const;
I'd expect the convention to be followed? It's going to mess me up if I have to check for -1 return on some listens() and not others. For example:
if (server.listen(8080)) { // I expect to be listening }
Will execute as expected for all but the HTTP servers, but will still execute as success when QAbstractHttpServer returns -1 when it actually failed.