diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2016-06-30 18:45:41 +0300 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> | 2016-07-05 19:21:06 +0000 |
commit | cddb344f3e24e3a61baf896161618c36a3f0c737 (patch) | |
tree | bc9cfdf6ebc12a787b02e8fc31cb4599d3454ff0 /tests/auto/network/socket | |
parent | 6c935dc74fa9e997144499d7aa34ef5aad389fbb (diff) |
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 <edward.welbourne@qt.io>
Diffstat (limited to 'tests/auto/network/socket')
-rw-r--r-- | tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
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")); |