diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp index 18f90a8..46b27cc 100644 --- a/src/network/socket/qnativesocketengine_winrt.cpp +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -467,14 +467,17 @@ void QNativeSocketEngine::close() // To close the connection properly (not with a hard reset) all pending read operation have to // be finished or cancelled. The API isn't available on Windows 8.1 though. ComPtr socket3; - hr = d->tcpSocket()->QueryInterface(IID_PPV_ARGS(&socket3)); - Q_ASSERT_SUCCEEDED(hr); + if (d->socketType == QAbstractSocket::TcpSocket && !d->tcpListener) { + hr = d->tcpSocket()->QueryInterface(IID_PPV_ARGS(&socket3)); + Q_ASSERT_SUCCEEDED(hr); - ComPtr action; - hr = socket3->CancelIOAsync(&action); - Q_ASSERT_SUCCEEDED(hr); - hr = QWinRTFunctions::await(action); - Q_ASSERT_SUCCEEDED(hr); + ComPtr action; + hr = socket3->CancelIOAsync(&action); + Q_ASSERT_SUCCEEDED(hr); + + hr = QWinRTFunctions::await(action); + Q_ASSERT_SUCCEEDED(hr); + } #endif // _MSC_VER >= 1900 if (d->readOp) {