1233 // clear the read buffer in connect mode so that bytes available returns 0 |
1233 // clear the read buffer in connect mode so that bytes available returns 0 |
1234 // if there already is a read notification pending then this will be processed first |
1234 // if there already is a read notification pending then this will be processed first |
1235 if (!readNotificationPending) |
1235 if (!readNotificationPending) |
1236 connectData->readBuffer.clear(); |
1236 connectData->readBuffer.clear(); |
1237 emitReadNotification(); |
1237 emitReadNotification(); |
|
1238 data->controlSocket->close(); |
|
1239 // cause a disconnect in the outer socket |
|
1240 emitWriteNotification(); |
1238 } else if (socks5State == Uninitialized |
1241 } else if (socks5State == Uninitialized |
1239 || socks5State == AuthenticationMethodsSent |
1242 || socks5State == AuthenticationMethodsSent |
1240 || socks5State == Authenticating |
1243 || socks5State == Authenticating |
1241 || socks5State == RequestMethodSent) { |
1244 || socks5State == RequestMethodSent) { |
1242 setErrorState(socks5State == Uninitialized ? ConnectError : ControlSocketError); |
1245 setErrorState(socks5State == Uninitialized ? ConnectError : ControlSocketError); |
1243 data->controlSocket->close(); |
1246 data->controlSocket->close(); |
1244 emitConnectionNotification(); |
1247 emitConnectionNotification(); |
1245 } else { |
1248 } else { |
1246 q_func()->setError(data->controlSocket->error(), data->controlSocket->errorString()); |
1249 q_func()->setError(data->controlSocket->error(), data->controlSocket->errorString()); |
1247 emitReadNotification(); |
1250 emitReadNotification(); |
|
1251 emitWriteNotification(); |
1248 } |
1252 } |
1249 } |
1253 } |
1250 |
1254 |
1251 void QSocks5SocketEnginePrivate::_q_controlSocketDisconnected() |
1255 void QSocks5SocketEnginePrivate::_q_controlSocketDisconnected() |
1252 { |
1256 { |
1621 return d->udpData->pendingDatagrams.head().data.size(); |
1625 return d->udpData->pendingDatagrams.head().data.size(); |
1622 return 0; |
1626 return 0; |
1623 } |
1627 } |
1624 #endif // QT_NO_UDPSOCKET |
1628 #endif // QT_NO_UDPSOCKET |
1625 |
1629 |
|
1630 qint64 QSocks5SocketEngine::bytesToWrite() const |
|
1631 { |
|
1632 Q_D(const QSocks5SocketEngine); |
|
1633 if (d->data && d->data->controlSocket) { |
|
1634 return d->data->controlSocket->bytesToWrite(); |
|
1635 } else { |
|
1636 return 0; |
|
1637 } |
|
1638 } |
|
1639 |
1626 int QSocks5SocketEngine::option(SocketOption option) const |
1640 int QSocks5SocketEngine::option(SocketOption option) const |
1627 { |
1641 { |
1628 Q_D(const QSocks5SocketEngine); |
1642 Q_D(const QSocks5SocketEngine); |
1629 if (d->data && d->data->controlSocket) { |
1643 if (d->data && d->data->controlSocket) { |
1630 // convert the enum and call the real socket |
1644 // convert the enum and call the real socket |