Details
-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
5.6, 5.11.0 Beta 2, 5.15.7
-
2
-
e83c9e4e8e74c57708fa88ee441584eee18f19b6 eacca3d2c2 (qt/qtbase/6.2) eacca3d2c2 (qt/tqtc-qtbase/6.2) fd3a0b5491 (qt/qtbase/6.3) fd3a0b5491 (qt/tqtc-qtbase/6.3) fd3a0b5491 (qt/tqtc-qtbase/6.3.0)
-
Team Two Foundation Sprint 52, Team B Foundation Sprint 53
Description
Setting QAbstractSocket::LowDelayOption option via QAbstractSocket::setSocketOption() has no effect if called before QAbstractSocket::connectToHost().
Example:
#include <QCoreApplication> #include <QHostAddress> #include <QTcpSocket> static void example1(QTcpSocket& socket) { socket.setSocketOption(QAbstractSocket::LowDelayOption, 1); socket.connectToHost(QHostAddress::LocalHost, 22); } static void example2(QTcpSocket& socket) { socket.connectToHost(QHostAddress::LocalHost, 22); socket.setSocketOption(QAbstractSocket::LowDelayOption, 1); } int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QTcpSocket socket; example1(socket); return app.exec(); }
`example1()` silently ignores setting `QAbstractSocket::LowDelayOption` and produce syscalls as attached in appendix log1.txt. On the other hand, `example2()`seems to work (see appendix log2.txt)
Actually, the documentation contains a hint, that `QAbstractSocket::KeepAliveOption` must be set before the socket is connected when running on Windows Runtime. In my opinion, setting an option via `QAbstractSocket::setSocketOption()` should be always possible and independent if the socket is already connected, connecting or idle. POSIX API also allows to configure socket options before establishing a connection.