From cddb344f3e24e3a61baf896161618c36a3f0c737 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Thu, 30 Jun 2016 18:45:41 +0300 Subject: QSslSocket: reset connection parameters on disconnect Otherwise socketDescriptor(), localPort(), localAddress(), peerPort(), peerAddress(), and peerName() remain uncleared until close() is called. This could take place when the connection is closed by the remote endpoint or the user calls disconnectFromHost(). After disconnecting, connection parameters are no longer valid, while I/O device is still opened and may have pending data for reading. Usually, the user reads all incoming data and closes the device independently. Change-Id: Ic898851c39137faf64019949910f0d94ebb79df7 Reviewed-by: Edward Welbourne --- tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp') diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index 382fbf08a8..6bb502edcb 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -1213,6 +1213,12 @@ void tst_QTcpSocket::connectDisconnectConnectDisconnect() QCOMPARE(socket->state(), QTcpSocket::UnconnectedState); QCOMPARE(socket->socketType(), QTcpSocket::TcpSocket); + QCOMPARE(socket->socketDescriptor(), qintptr(-1)); + QCOMPARE(int(socket->localPort()), 0); + QCOMPARE(socket->localAddress(), QHostAddress()); + QCOMPARE(int(socket->peerPort()), 0); + QCOMPARE(socket->peerAddress(), QHostAddress()); + socket->connectToHost(QtNetworkSettings::serverName(), 143); QVERIFY(socket->waitForReadyRead(10000)); QCOMPARE(QString::fromLatin1(socket->read(4)), QString("* OK")); -- cgit v1.2.3