Revert "QAbstractSocket: deprecate 'error' member-function"
This reverts commit 94b3dd77f29a00ebbd1efdc66d75f57e1c75b152. The patch fixes ambiguity between a getter and a signal by changing the getter name, but we still have to rename the signal to follow the signals naming convention. Revert the commit to keep the getter as is and change the signal name instead. Change-Id: I0dd60cf1ae9d1bd95beeb8ad58661ca4b1fb63b9 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
e1920f6593
commit
6d18e4a2b8
@ -103,7 +103,7 @@ void FortuneThread::run()
|
|||||||
//! [6] //! [8]
|
//! [6] //! [8]
|
||||||
|
|
||||||
if (!socket.waitForConnected(Timeout)) {
|
if (!socket.waitForConnected(Timeout)) {
|
||||||
emit error(socket.socketError(), socket.errorString());
|
emit error(socket.error(), socket.errorString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//! [8] //! [11]
|
//! [8] //! [11]
|
||||||
@ -115,7 +115,7 @@ void FortuneThread::run()
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
if (!socket.waitForReadyRead(Timeout)) {
|
if (!socket.waitForReadyRead(Timeout)) {
|
||||||
emit error(socket.socketError(), socket.errorString());
|
emit error(socket.error(), socket.errorString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ void FortuneThread::run()
|
|||||||
QTcpSocket tcpSocket;
|
QTcpSocket tcpSocket;
|
||||||
//! [1] //! [2]
|
//! [1] //! [2]
|
||||||
if (!tcpSocket.setSocketDescriptor(socketDescriptor)) {
|
if (!tcpSocket.setSocketDescriptor(socketDescriptor)) {
|
||||||
emit error(tcpSocket.socketError());
|
emit error(tcpSocket.error());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//! [2] //! [3]
|
//! [2] //! [3]
|
||||||
|
@ -867,7 +867,7 @@ void TorrentClient::removeClient()
|
|||||||
|
|
||||||
// Remove the host from our list of known peers if the connection
|
// Remove the host from our list of known peers if the connection
|
||||||
// failed.
|
// failed.
|
||||||
if (client->peer() && client->socketError() == QAbstractSocket::ConnectionRefusedError)
|
if (client->peer() && client->error() == QAbstractSocket::ConnectionRefusedError)
|
||||||
d->peers.removeAll(client->peer());
|
d->peers.removeAll(client->peer());
|
||||||
|
|
||||||
// Remove the client from RateController and all structures.
|
// Remove the client from RateController and all structures.
|
||||||
|
@ -233,7 +233,7 @@ void QHttpProtocolHandler::_q_readyRead()
|
|||||||
char c;
|
char c;
|
||||||
qint64 ret = m_socket->peek(&c, 1);
|
qint64 ret = m_socket->peek(&c, 1);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
m_channel->_q_error(m_socket->socketError());
|
m_channel->_q_error(m_socket->error());
|
||||||
// We still need to handle the reply so it emits its signals etc.
|
// We still need to handle the reply so it emits its signals etc.
|
||||||
if (m_reply)
|
if (m_reply)
|
||||||
_q_receiveReply();
|
_q_receiveReply();
|
||||||
|
@ -242,9 +242,9 @@ void QNetworkAccessDebugPipeBackend::closeDownstreamChannel()
|
|||||||
|
|
||||||
void QNetworkAccessDebugPipeBackend::socketError()
|
void QNetworkAccessDebugPipeBackend::socketError()
|
||||||
{
|
{
|
||||||
qWarning("QNetworkAccessDebugPipeBackend::socketError() %d",socket.socketError());
|
qWarning("QNetworkAccessDebugPipeBackend::socketError() %d",socket.error());
|
||||||
QNetworkReply::NetworkError code;
|
QNetworkReply::NetworkError code;
|
||||||
switch (socket.socketError()) {
|
switch (socket.error()) {
|
||||||
case QAbstractSocket::RemoteHostClosedError:
|
case QAbstractSocket::RemoteHostClosedError:
|
||||||
return; // socketDisconnected will be called
|
return; // socketDisconnected will be called
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@
|
|||||||
connections, you will have to register it with Q_DECLARE_METATYPE() and
|
connections, you will have to register it with Q_DECLARE_METATYPE() and
|
||||||
qRegisterMetaType().
|
qRegisterMetaType().
|
||||||
|
|
||||||
\sa socketError(), errorString(), {Creating Custom Qt Types}
|
\sa error(), errorString(), {Creating Custom Qt Types}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -329,7 +329,7 @@
|
|||||||
is non-blocking).
|
is non-blocking).
|
||||||
|
|
||||||
\value UnknownSocketError An unidentified error occurred.
|
\value UnknownSocketError An unidentified error occurred.
|
||||||
\sa QAbstractSocket::socketError()
|
\sa QAbstractSocket::error()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -2092,7 +2092,7 @@ QVariant QAbstractSocket::socketOption(QAbstractSocket::SocketOption option)
|
|||||||
Waits until the socket is connected, up to \a msecs
|
Waits until the socket is connected, up to \a msecs
|
||||||
milliseconds. If the connection has been established, this
|
milliseconds. If the connection has been established, this
|
||||||
function returns \c true; otherwise it returns \c false. In the case
|
function returns \c true; otherwise it returns \c false. In the case
|
||||||
where it returns \c false, you can call socketError() to determine
|
where it returns \c false, you can call error() to determine
|
||||||
the cause of the error.
|
the cause of the error.
|
||||||
|
|
||||||
The following example waits up to one second for a connection
|
The following example waits up to one second for a connection
|
||||||
@ -2864,7 +2864,7 @@ void QAbstractSocket::setReadBufferSize(qint64 size)
|
|||||||
/*!
|
/*!
|
||||||
Returns the state of the socket.
|
Returns the state of the socket.
|
||||||
|
|
||||||
\sa socketError()
|
\sa error()
|
||||||
*/
|
*/
|
||||||
QAbstractSocket::SocketState QAbstractSocket::state() const
|
QAbstractSocket::SocketState QAbstractSocket::state() const
|
||||||
{
|
{
|
||||||
@ -2891,35 +2891,16 @@ QAbstractSocket::SocketType QAbstractSocket::socketType() const
|
|||||||
return d_func()->socketType;
|
return d_func()->socketType;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_DEPRECATED_SINCE(5, 15)
|
|
||||||
/*!
|
/*!
|
||||||
\deprecated
|
|
||||||
|
|
||||||
Use socketError() instead.
|
|
||||||
|
|
||||||
Returns the type of error that last occurred.
|
|
||||||
|
|
||||||
\sa state(), errorString(), socketError()
|
|
||||||
*/
|
|
||||||
QAbstractSocket::SocketError QAbstractSocket::error() const
|
|
||||||
{
|
|
||||||
return socketError();
|
|
||||||
}
|
|
||||||
#endif // QT_DEPRECATED_SINCE(5, 15)
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\since 5.15
|
|
||||||
|
|
||||||
Returns the type of error that last occurred.
|
Returns the type of error that last occurred.
|
||||||
|
|
||||||
\sa state(), errorString()
|
\sa state(), errorString()
|
||||||
*/
|
*/
|
||||||
QAbstractSocket::SocketError QAbstractSocket::socketError() const
|
QAbstractSocket::SocketError QAbstractSocket::error() const
|
||||||
{
|
{
|
||||||
return d_func()->socketError;
|
return d_func()->socketError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Sets the type of error that last occurred to \a socketError.
|
Sets the type of error that last occurred to \a socketError.
|
||||||
|
|
||||||
|
@ -180,12 +180,7 @@ public:
|
|||||||
|
|
||||||
SocketType socketType() const;
|
SocketType socketType() const;
|
||||||
SocketState state() const;
|
SocketState state() const;
|
||||||
|
SocketError error() const;
|
||||||
#if QT_DEPRECATED_SINCE(5, 15)
|
|
||||||
QT_DEPRECATED_X("Use socketError()") SocketError error() const;
|
|
||||||
#endif // QT_DEPRECATED_SINCE(5, 15)
|
|
||||||
|
|
||||||
SocketError socketError() const;
|
|
||||||
|
|
||||||
// from QIODevice
|
// from QIODevice
|
||||||
void close() override;
|
void close() override;
|
||||||
|
@ -370,8 +370,8 @@ bool QHttpSocketEngine::waitForRead(int msecs, bool *timedOut)
|
|||||||
if (!d->socket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) {
|
if (!d->socket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) {
|
||||||
if (d->socket->state() == QAbstractSocket::UnconnectedState)
|
if (d->socket->state() == QAbstractSocket::UnconnectedState)
|
||||||
return true;
|
return true;
|
||||||
setError(d->socket->socketError(), d->socket->errorString());
|
setError(d->socket->error(), d->socket->errorString());
|
||||||
if (timedOut && d->socket->socketError() == QAbstractSocket::SocketTimeoutError)
|
if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError)
|
||||||
*timedOut = true;
|
*timedOut = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -385,8 +385,8 @@ bool QHttpSocketEngine::waitForRead(int msecs, bool *timedOut)
|
|||||||
|
|
||||||
// Report any error that may occur.
|
// Report any error that may occur.
|
||||||
if (d->state != Connected) {
|
if (d->state != Connected) {
|
||||||
setError(d->socket->socketError(), d->socket->errorString());
|
setError(d->socket->error(), d->socket->errorString());
|
||||||
if (timedOut && d->socket->socketError() == QAbstractSocket::SocketTimeoutError)
|
if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError)
|
||||||
*timedOut = true;
|
*timedOut = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -401,7 +401,7 @@ bool QHttpSocketEngine::waitForWrite(int msecs, bool *timedOut)
|
|||||||
if (d->state == Connected) {
|
if (d->state == Connected) {
|
||||||
if (d->socket->bytesToWrite()) {
|
if (d->socket->bytesToWrite()) {
|
||||||
if (!d->socket->waitForBytesWritten(msecs)) {
|
if (!d->socket->waitForBytesWritten(msecs)) {
|
||||||
if (d->socket->socketError() == QAbstractSocket::SocketTimeoutError && timedOut)
|
if (d->socket->error() == QAbstractSocket::SocketTimeoutError && timedOut)
|
||||||
*timedOut = true;
|
*timedOut = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -421,7 +421,8 @@ bool QHttpSocketEngine::waitForWrite(int msecs, bool *timedOut)
|
|||||||
|
|
||||||
// Report any error that may occur.
|
// Report any error that may occur.
|
||||||
if (d->state != Connected) {
|
if (d->state != Connected) {
|
||||||
if (timedOut && d->socket->socketError() == QAbstractSocket::SocketTimeoutError)
|
// setError(d->socket->error(), d->socket->errorString());
|
||||||
|
if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError)
|
||||||
*timedOut = true;
|
*timedOut = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,7 +464,7 @@ void QLocalSocket::disconnectFromServer()
|
|||||||
QLocalSocket::LocalSocketError QLocalSocket::error() const
|
QLocalSocket::LocalSocketError QLocalSocket::error() const
|
||||||
{
|
{
|
||||||
Q_D(const QLocalSocket);
|
Q_D(const QLocalSocket);
|
||||||
switch (d->unixSocket.socketError()) {
|
switch (d->unixSocket.error()) {
|
||||||
case QAbstractSocket::ConnectionRefusedError:
|
case QAbstractSocket::ConnectionRefusedError:
|
||||||
return QLocalSocket::ConnectionRefusedError;
|
return QLocalSocket::ConnectionRefusedError;
|
||||||
case QAbstractSocket::RemoteHostClosedError:
|
case QAbstractSocket::RemoteHostClosedError:
|
||||||
|
@ -594,7 +594,7 @@ void QSocks5SocketEnginePrivate::setErrorState(Socks5State state, const QString
|
|||||||
|
|
||||||
case ConnectError:
|
case ConnectError:
|
||||||
case ControlSocketError: {
|
case ControlSocketError: {
|
||||||
QAbstractSocket::SocketError controlSocketError = data->controlSocket->socketError();
|
QAbstractSocket::SocketError controlSocketError = data->controlSocket->error();
|
||||||
if (socks5State != Connected) {
|
if (socks5State != Connected) {
|
||||||
switch (controlSocketError) {
|
switch (controlSocketError) {
|
||||||
case QAbstractSocket::ConnectionRefusedError:
|
case QAbstractSocket::ConnectionRefusedError:
|
||||||
@ -918,7 +918,7 @@ void QSocks5SocketEnginePrivate::_q_emitPendingReadNotification()
|
|||||||
return;
|
return;
|
||||||
// check if there needs to be a new zero read notification
|
// check if there needs to be a new zero read notification
|
||||||
if (data && data->controlSocket->state() == QAbstractSocket::UnconnectedState
|
if (data && data->controlSocket->state() == QAbstractSocket::UnconnectedState
|
||||||
&& data->controlSocket->socketError() == QAbstractSocket::RemoteHostClosedError) {
|
&& data->controlSocket->error() == QAbstractSocket::RemoteHostClosedError) {
|
||||||
connectData->readBuffer.clear();
|
connectData->readBuffer.clear();
|
||||||
emitReadNotification();
|
emitReadNotification();
|
||||||
}
|
}
|
||||||
@ -1256,7 +1256,7 @@ void QSocks5SocketEnginePrivate::_q_controlSocketError(QAbstractSocket::SocketEr
|
|||||||
data->controlSocket->close();
|
data->controlSocket->close();
|
||||||
emitConnectionNotification();
|
emitConnectionNotification();
|
||||||
} else {
|
} else {
|
||||||
q_func()->setError(data->controlSocket->socketError(), data->controlSocket->errorString());
|
q_func()->setError(data->controlSocket->error(), data->controlSocket->errorString());
|
||||||
emitReadNotification();
|
emitReadNotification();
|
||||||
emitWriteNotification();
|
emitWriteNotification();
|
||||||
}
|
}
|
||||||
@ -1348,7 +1348,7 @@ bool QSocks5SocketEngine::bind(const QHostAddress &addr, quint16 port)
|
|||||||
if (d->mode == QSocks5SocketEnginePrivate::UdpAssociateMode) {
|
if (d->mode == QSocks5SocketEnginePrivate::UdpAssociateMode) {
|
||||||
if (!d->udpData->udpSocket->bind(address, port)) {
|
if (!d->udpData->udpSocket->bind(address, port)) {
|
||||||
QSOCKS5_Q_DEBUG << "local udp bind failed";
|
QSOCKS5_Q_DEBUG << "local udp bind failed";
|
||||||
setError(d->udpData->udpSocket->socketError(), d->udpData->udpSocket->errorString());
|
setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
d->localAddress = d->udpData->udpSocket->localAddress();
|
d->localAddress = d->udpData->udpSocket->localAddress();
|
||||||
@ -1656,8 +1656,8 @@ qint64 QSocks5SocketEngine::writeDatagram(const char *data, qint64 len, const QI
|
|||||||
}
|
}
|
||||||
if (d->udpData->udpSocket->writeDatagram(sealedBuf, d->udpData->associateAddress, d->udpData->associatePort) != sealedBuf.size()) {
|
if (d->udpData->udpSocket->writeDatagram(sealedBuf, d->udpData->associateAddress, d->udpData->associatePort) != sealedBuf.size()) {
|
||||||
//### try frgamenting
|
//### try frgamenting
|
||||||
if (d->udpData->udpSocket->socketError() == QAbstractSocket::DatagramTooLargeError)
|
if (d->udpData->udpSocket->error() == QAbstractSocket::DatagramTooLargeError)
|
||||||
setError(d->udpData->udpSocket->socketError(), d->udpData->udpSocket->errorString());
|
setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString());
|
||||||
//### else maybe more serious error
|
//### else maybe more serious error
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1727,7 +1727,7 @@ bool QSocks5SocketEnginePrivate::waitForConnected(int msecs, bool *timedOut)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
setErrorState(QSocks5SocketEnginePrivate::ControlSocketError);
|
setErrorState(QSocks5SocketEnginePrivate::ControlSocketError);
|
||||||
if (timedOut && data->controlSocket->socketError() == QAbstractSocket::SocketTimeoutError)
|
if (timedOut && data->controlSocket->error() == QAbstractSocket::SocketTimeoutError)
|
||||||
*timedOut = true;
|
*timedOut = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1765,8 +1765,8 @@ bool QSocks5SocketEngine::waitForRead(int msecs, bool *timedOut)
|
|||||||
if (d->data->controlSocket->state() == QAbstractSocket::UnconnectedState)
|
if (d->data->controlSocket->state() == QAbstractSocket::UnconnectedState)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
setError(d->data->controlSocket->socketError(), d->data->controlSocket->errorString());
|
setError(d->data->controlSocket->error(), d->data->controlSocket->errorString());
|
||||||
if (timedOut && d->data->controlSocket->socketError() == QAbstractSocket::SocketTimeoutError)
|
if (timedOut && d->data->controlSocket->error() == QAbstractSocket::SocketTimeoutError)
|
||||||
*timedOut = true;
|
*timedOut = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1775,8 +1775,8 @@ bool QSocks5SocketEngine::waitForRead(int msecs, bool *timedOut)
|
|||||||
} else {
|
} else {
|
||||||
while (!d->readNotificationActivated) {
|
while (!d->readNotificationActivated) {
|
||||||
if (!d->udpData->udpSocket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) {
|
if (!d->udpData->udpSocket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) {
|
||||||
setError(d->udpData->udpSocket->socketError(), d->udpData->udpSocket->errorString());
|
setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString());
|
||||||
if (timedOut && d->udpData->udpSocket->socketError() == QAbstractSocket::SocketTimeoutError)
|
if (timedOut && d->udpData->udpSocket->error() == QAbstractSocket::SocketTimeoutError)
|
||||||
*timedOut = true;
|
*timedOut = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1125,7 +1125,7 @@ qint64 QDtlsPrivateOpenSSL::writeDatagramEncrypted(QUdpSocket *socket,
|
|||||||
// some errors can be just ignored (it's UDP, not TCP after all).
|
// some errors can be just ignored (it's UDP, not TCP after all).
|
||||||
// Unlike QSslSocket we do not abort though.
|
// Unlike QSslSocket we do not abort though.
|
||||||
QString description(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
|
QString description(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
|
||||||
if (socket->socketError() != QAbstractSocket::UnknownSocketError && description.isEmpty()) {
|
if (socket->error() != QAbstractSocket::UnknownSocketError && description.isEmpty()) {
|
||||||
setDtlsError(QDtlsError::UnderlyingSocketError, socket->errorString());
|
setDtlsError(QDtlsError::UnderlyingSocketError, socket->errorString());
|
||||||
} else {
|
} else {
|
||||||
setDtlsError(QDtlsError::TlsFatalError,
|
setDtlsError(QDtlsError::TlsFatalError,
|
||||||
|
@ -565,7 +565,7 @@ bool QSslSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState state
|
|||||||
d->createPlainSocket(openMode);
|
d->createPlainSocket(openMode);
|
||||||
bool retVal = d->plainSocket->setSocketDescriptor(socketDescriptor, state, openMode);
|
bool retVal = d->plainSocket->setSocketDescriptor(socketDescriptor, state, openMode);
|
||||||
d->cachedSocketDescriptor = d->plainSocket->socketDescriptor();
|
d->cachedSocketDescriptor = d->plainSocket->socketDescriptor();
|
||||||
d->setError(d->plainSocket->socketError(), d->plainSocket->errorString());
|
d->setError(d->plainSocket->error(), d->plainSocket->errorString());
|
||||||
setSocketState(state);
|
setSocketState(state);
|
||||||
setOpenMode(openMode);
|
setOpenMode(openMode);
|
||||||
setLocalPort(d->plainSocket->localPort());
|
setLocalPort(d->plainSocket->localPort());
|
||||||
@ -1670,7 +1670,7 @@ bool QSslSocket::waitForConnected(int msecs)
|
|||||||
bool retVal = d->plainSocket->waitForConnected(msecs);
|
bool retVal = d->plainSocket->waitForConnected(msecs);
|
||||||
if (!retVal) {
|
if (!retVal) {
|
||||||
setSocketState(d->plainSocket->state());
|
setSocketState(d->plainSocket->state());
|
||||||
d->setError(d->plainSocket->socketError(), d->plainSocket->errorString());
|
d->setError(d->plainSocket->error(), d->plainSocket->errorString());
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
@ -1839,7 +1839,7 @@ bool QSslSocket::waitForDisconnected(int msecs)
|
|||||||
bool retVal = d->plainSocket->waitForDisconnected(qt_subtract_from_timeout(msecs, stopWatch.elapsed()));
|
bool retVal = d->plainSocket->waitForDisconnected(qt_subtract_from_timeout(msecs, stopWatch.elapsed()));
|
||||||
if (!retVal) {
|
if (!retVal) {
|
||||||
setSocketState(d->plainSocket->state());
|
setSocketState(d->plainSocket->state());
|
||||||
d->setError(d->plainSocket->socketError(), d->plainSocket->errorString());
|
d->setError(d->plainSocket->error(), d->plainSocket->errorString());
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
@ -2711,7 +2711,7 @@ void QSslSocketPrivate::_q_errorSlot(QAbstractSocket::SocketError error)
|
|||||||
readBufferMaxSize = tmpReadBufferMaxSize;
|
readBufferMaxSize = tmpReadBufferMaxSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString());
|
setErrorAndEmit(plainSocket->error(), plainSocket->errorString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -1009,7 +1009,7 @@ void QSslSocketBackendPrivate::transmit()
|
|||||||
if (actualWritten < 0) {
|
if (actualWritten < 0) {
|
||||||
//plain socket write fails if it was in the pending close state.
|
//plain socket write fails if it was in the pending close state.
|
||||||
const ScopedBool bg(inSetAndEmitError, true);
|
const ScopedBool bg(inSetAndEmitError, true);
|
||||||
setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString());
|
setErrorAndEmit(plainSocket->error(), plainSocket->errorString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
transmitting = true;
|
transmitting = true;
|
||||||
|
@ -582,7 +582,7 @@ bool QSslSocketBackendPrivate::sendToken(void *token, unsigned long tokenLength,
|
|||||||
if (written != qint64(tokenLength)) {
|
if (written != qint64(tokenLength)) {
|
||||||
// Failed to write/buffer everything or an error occurred
|
// Failed to write/buffer everything or an error occurred
|
||||||
if (emitError)
|
if (emitError)
|
||||||
setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString());
|
setErrorAndEmit(plainSocket->error(), plainSocket->errorString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -1292,7 +1292,7 @@ void QSslSocketBackendPrivate::transmit()
|
|||||||
if (bytesWritten >= 0) {
|
if (bytesWritten >= 0) {
|
||||||
totalBytesWritten += bytesWritten;
|
totalBytesWritten += bytesWritten;
|
||||||
} else {
|
} else {
|
||||||
setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString());
|
setErrorAndEmit(plainSocket->error(), plainSocket->errorString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ public:
|
|||||||
if (!s.peerAddress().isNull())
|
if (!s.peerAddress().isNull())
|
||||||
debug << ", peer=" << s.peerAddress().toString() << ':' << s.peerPort();
|
debug << ", peer=" << s.peerAddress().toString() << ':' << s.peerPort();
|
||||||
debug << ", type=" << s.socketType() << ", state=" << s.state()
|
debug << ", type=" << s.socketType() << ", state=" << s.state()
|
||||||
<< ", error=" << s.socketError() << ": " << s.errorString();
|
<< ", error=" << s.error() << ": " << s.errorString();
|
||||||
return result.toLocal8Bit();
|
return result.toLocal8Bit();
|
||||||
}
|
}
|
||||||
#endif // QT_NETWORK_LIB
|
#endif // QT_NETWORK_LIB
|
||||||
|
@ -1111,7 +1111,7 @@ protected:
|
|||||||
|
|
||||||
// get the "request" packet
|
// get the "request" packet
|
||||||
if (!client->waitForReadyRead(2000)) {
|
if (!client->waitForReadyRead(2000)) {
|
||||||
qDebug() << "FastSender:" << client->socketError() << "waiting for \"request\" packet";
|
qDebug() << "FastSender:" << client->error() << "waiting for \"request\" packet";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
client->readAll(); // we're not interested in the actual contents (e.g. HTTP request)
|
client->readAll(); // we're not interested in the actual contents (e.g. HTTP request)
|
||||||
@ -1148,7 +1148,7 @@ protected:
|
|||||||
while (client->bytesToWrite() > 0) {
|
while (client->bytesToWrite() > 0) {
|
||||||
qDebug() << "Still having" << client->bytesToWrite() << "bytes to write, doing that now";
|
qDebug() << "Still having" << client->bytesToWrite() << "bytes to write, doing that now";
|
||||||
if (!client->waitForBytesWritten(10000)) {
|
if (!client->waitForBytesWritten(10000)) {
|
||||||
qDebug() << "ERROR: FastSender:" << client->socketError() << "cleaning up residue";
|
qDebug() << "ERROR: FastSender:" << client->error() << "cleaning up residue";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1168,7 +1168,7 @@ protected:
|
|||||||
|
|
||||||
while (client->bytesToWrite() > 0) {
|
while (client->bytesToWrite() > 0) {
|
||||||
if (!client->waitForBytesWritten(10000)) {
|
if (!client->waitForBytesWritten(10000)) {
|
||||||
qDebug() << "ERROR: FastSender:" << client->socketError() << "during blocking write";
|
qDebug() << "ERROR: FastSender:" << client->error() << "during blocking write";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ void tst_QHttpSocketEngine::errorTest()
|
|||||||
QTestEventLoop::instance().enterLoop(30);
|
QTestEventLoop::instance().enterLoop(30);
|
||||||
QVERIFY(!QTestEventLoop::instance().timeout());
|
QVERIFY(!QTestEventLoop::instance().timeout());
|
||||||
|
|
||||||
QCOMPARE(int(socket.socketError()), expectedError);
|
QCOMPARE(int(socket.error()), expectedError);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -288,7 +288,7 @@ void tst_QSocks5SocketEngine::errorTest()
|
|||||||
QTestEventLoop::instance().enterLoop(10);
|
QTestEventLoop::instance().enterLoop(10);
|
||||||
QVERIFY(!QTestEventLoop::instance().timeout());
|
QVERIFY(!QTestEventLoop::instance().timeout());
|
||||||
|
|
||||||
QCOMPARE(int(socket.socketError()), expectedError);
|
QCOMPARE(int(socket.error()), expectedError);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
@ -1011,7 +1011,7 @@ void tst_QSocks5SocketEngine::incomplete()
|
|||||||
QTestEventLoop::instance().enterLoop(70);
|
QTestEventLoop::instance().enterLoop(70);
|
||||||
QVERIFY(!QTestEventLoop::instance().timeout());
|
QVERIFY(!QTestEventLoop::instance().timeout());
|
||||||
|
|
||||||
QCOMPARE(socket.socketError(), QAbstractSocket::ProxyConnectionClosedError);
|
QCOMPARE(socket.error(), QAbstractSocket::ProxyConnectionClosedError);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -493,7 +493,7 @@ void tst_QTcpSocket::constructing()
|
|||||||
QCOMPARE(socket->peerAddress(), QHostAddress());
|
QCOMPARE(socket->peerAddress(), QHostAddress());
|
||||||
QCOMPARE(socket->readChannelCount(), 0);
|
QCOMPARE(socket->readChannelCount(), 0);
|
||||||
QCOMPARE(socket->writeChannelCount(), 0);
|
QCOMPARE(socket->writeChannelCount(), 0);
|
||||||
QCOMPARE(socket->socketError(), QTcpSocket::UnknownSocketError);
|
QCOMPARE(socket->error(), QTcpSocket::UnknownSocketError);
|
||||||
QCOMPARE(socket->errorString(), QString("Unknown error"));
|
QCOMPARE(socket->errorString(), QString("Unknown error"));
|
||||||
|
|
||||||
// Check the state of the socket layer?
|
// Check the state of the socket layer?
|
||||||
@ -603,7 +603,7 @@ void tst_QTcpSocket::bind()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool bindSuccess = socket->bind(addr, port);
|
bool bindSuccess = socket->bind(addr, port);
|
||||||
if (!bindSuccess && randomPort && socket->socketError() == QTcpSocket::AddressInUseError) {
|
if (!bindSuccess && randomPort && socket->error() == QTcpSocket::AddressInUseError) {
|
||||||
// we may have been unlucky and hit an already open port, so try another
|
// we may have been unlucky and hit an already open port, so try another
|
||||||
--attemptsLeft;
|
--attemptsLeft;
|
||||||
continue;
|
continue;
|
||||||
@ -730,7 +730,7 @@ void tst_QTcpSocket::setInvalidSocketDescriptor()
|
|||||||
QVERIFY(!socket->setSocketDescriptor(-5, QTcpSocket::UnconnectedState));
|
QVERIFY(!socket->setSocketDescriptor(-5, QTcpSocket::UnconnectedState));
|
||||||
QCOMPARE(socket->socketDescriptor(), (qintptr)-1);
|
QCOMPARE(socket->socketDescriptor(), (qintptr)-1);
|
||||||
|
|
||||||
QCOMPARE(socket->socketError(), QTcpSocket::UnsupportedSocketOperationError);
|
QCOMPARE(socket->error(), QTcpSocket::UnsupportedSocketOperationError);
|
||||||
|
|
||||||
delete socket;
|
delete socket;
|
||||||
}
|
}
|
||||||
@ -893,7 +893,7 @@ void tst_QTcpSocket::hostNotFound()
|
|||||||
"when we expect 404", Continue);
|
"when we expect 404", Continue);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
QCOMPARE(int(socket->socketError()), int(QTcpSocket::HostNotFoundError));
|
QCOMPARE(int(socket->error()), int(QTcpSocket::HostNotFoundError));
|
||||||
|
|
||||||
delete socket;
|
delete socket;
|
||||||
}
|
}
|
||||||
@ -919,7 +919,7 @@ void tst_QTcpSocket::timeoutConnect()
|
|||||||
QVERIFY(timer.elapsed() < 150);
|
QVERIFY(timer.elapsed() < 150);
|
||||||
QVERIFY(!socket->waitForConnected(1000)); //200ms is too short when using SOCKS proxy authentication
|
QVERIFY(!socket->waitForConnected(1000)); //200ms is too short when using SOCKS proxy authentication
|
||||||
QCOMPARE(socket->state(), QTcpSocket::UnconnectedState);
|
QCOMPARE(socket->state(), QTcpSocket::UnconnectedState);
|
||||||
QCOMPARE(int(socket->socketError()), int(QTcpSocket::SocketTimeoutError));
|
QCOMPARE(int(socket->error()), int(QTcpSocket::SocketTimeoutError));
|
||||||
QCOMPARE(socket->readChannelCount(), 0);
|
QCOMPARE(socket->readChannelCount(), 0);
|
||||||
QCOMPARE(socket->writeChannelCount(), 0);
|
QCOMPARE(socket->writeChannelCount(), 0);
|
||||||
|
|
||||||
@ -1238,7 +1238,7 @@ void tst_QTcpSocket::openCloseOpenClose()
|
|||||||
QCOMPARE(socket->localAddress(), QHostAddress());
|
QCOMPARE(socket->localAddress(), QHostAddress());
|
||||||
QCOMPARE((int) socket->peerPort(), 0);
|
QCOMPARE((int) socket->peerPort(), 0);
|
||||||
QCOMPARE(socket->peerAddress(), QHostAddress());
|
QCOMPARE(socket->peerAddress(), QHostAddress());
|
||||||
QCOMPARE(socket->socketError(), QTcpSocket::UnknownSocketError);
|
QCOMPARE(socket->error(), QTcpSocket::UnknownSocketError);
|
||||||
QCOMPARE(socket->errorString(), QString("Unknown error"));
|
QCOMPARE(socket->errorString(), QString("Unknown error"));
|
||||||
|
|
||||||
QCOMPARE(socket->state(), QTcpSocket::UnconnectedState);
|
QCOMPARE(socket->state(), QTcpSocket::UnconnectedState);
|
||||||
@ -1392,7 +1392,7 @@ protected:
|
|||||||
while (!quit) {
|
while (!quit) {
|
||||||
if (socket->waitForDisconnected(500))
|
if (socket->waitForDisconnected(500))
|
||||||
break;
|
break;
|
||||||
if (socket->socketError() != QAbstractSocket::SocketTimeoutError)
|
if (socket->error() != QAbstractSocket::SocketTimeoutError)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1628,8 +1628,8 @@ void tst_QTcpSocket::readLine()
|
|||||||
|
|
||||||
QVERIFY(!socket->waitForReadyRead(100));
|
QVERIFY(!socket->waitForReadyRead(100));
|
||||||
QCOMPARE(socket->readLine(buffer, sizeof(buffer)), qint64(0));
|
QCOMPARE(socket->readLine(buffer, sizeof(buffer)), qint64(0));
|
||||||
QVERIFY(socket->socketError() == QAbstractSocket::SocketTimeoutError
|
QVERIFY(socket->error() == QAbstractSocket::SocketTimeoutError
|
||||||
|| socket->socketError() == QAbstractSocket::RemoteHostClosedError);
|
|| socket->error() == QAbstractSocket::RemoteHostClosedError);
|
||||||
QCOMPARE(socket->bytesAvailable(), qint64(0));
|
QCOMPARE(socket->bytesAvailable(), qint64(0));
|
||||||
|
|
||||||
socket->close();
|
socket->close();
|
||||||
@ -1778,11 +1778,11 @@ void tst_QTcpSocket::dontCloseOnTimeout()
|
|||||||
QTcpSocket *socket = newSocket();
|
QTcpSocket *socket = newSocket();
|
||||||
socket->connectToHost(serverAddress, server.serverPort());
|
socket->connectToHost(serverAddress, server.serverPort());
|
||||||
QVERIFY(!socket->waitForReadyRead(100));
|
QVERIFY(!socket->waitForReadyRead(100));
|
||||||
QCOMPARE(socket->socketError(), QTcpSocket::SocketTimeoutError);
|
QCOMPARE(socket->error(), QTcpSocket::SocketTimeoutError);
|
||||||
QVERIFY(socket->isOpen());
|
QVERIFY(socket->isOpen());
|
||||||
|
|
||||||
QVERIFY(!socket->waitForDisconnected(100));
|
QVERIFY(!socket->waitForDisconnected(100));
|
||||||
QCOMPARE(socket->socketError(), QTcpSocket::SocketTimeoutError);
|
QCOMPARE(socket->error(), QTcpSocket::SocketTimeoutError);
|
||||||
QVERIFY(socket->isOpen());
|
QVERIFY(socket->isOpen());
|
||||||
|
|
||||||
delete socket;
|
delete socket;
|
||||||
@ -2034,7 +2034,7 @@ void tst_QTcpSocket::remoteCloseError()
|
|||||||
|
|
||||||
QCOMPARE(disconnectedSpy.count(), 1);
|
QCOMPARE(disconnectedSpy.count(), 1);
|
||||||
QCOMPARE(errorSpy.count(), 1);
|
QCOMPARE(errorSpy.count(), 1);
|
||||||
QCOMPARE(clientSocket->socketError(), QAbstractSocket::RemoteHostClosedError);
|
QCOMPARE(clientSocket->error(), QAbstractSocket::RemoteHostClosedError);
|
||||||
|
|
||||||
delete serverSocket;
|
delete serverSocket;
|
||||||
|
|
||||||
@ -2402,7 +2402,7 @@ void tst_QTcpSocket::zeroAndMinusOneReturns()
|
|||||||
|
|
||||||
socket->write("GET / HTTP/1.0\r\n\r\n");
|
socket->write("GET / HTTP/1.0\r\n\r\n");
|
||||||
QVERIFY(socket->waitForDisconnected(15000));
|
QVERIFY(socket->waitForDisconnected(15000));
|
||||||
QCOMPARE(socket->socketError(), QAbstractSocket::RemoteHostClosedError);
|
QCOMPARE(socket->error(), QAbstractSocket::RemoteHostClosedError);
|
||||||
|
|
||||||
QCOMPARE(socket->write("BLUBBER"), qint64(-1));
|
QCOMPARE(socket->write("BLUBBER"), qint64(-1));
|
||||||
QVERIFY(socket->getChar(c));
|
QVERIFY(socket->getChar(c));
|
||||||
@ -2451,7 +2451,7 @@ void tst_QTcpSocket::connectionRefused()
|
|||||||
QVERIFY2(!timeout(), "Network timeout");
|
QVERIFY2(!timeout(), "Network timeout");
|
||||||
|
|
||||||
QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
|
QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
|
||||||
QCOMPARE(socket->socketError(), QAbstractSocket::ConnectionRefusedError);
|
QCOMPARE(socket->error(), QAbstractSocket::ConnectionRefusedError);
|
||||||
|
|
||||||
QCOMPARE(stateSpy.count(), 3);
|
QCOMPARE(stateSpy.count(), 3);
|
||||||
QCOMPARE(qvariant_cast<QAbstractSocket::SocketState>(stateSpy.at(0).at(0)), QAbstractSocket::HostLookupState);
|
QCOMPARE(qvariant_cast<QAbstractSocket::SocketState>(stateSpy.at(0).at(0)), QAbstractSocket::HostLookupState);
|
||||||
@ -2574,7 +2574,7 @@ void tst_QTcpSocket::connectToMultiIP()
|
|||||||
socket->connectToHost("multi.dev.qt-project.org", 81);
|
socket->connectToHost("multi.dev.qt-project.org", 81);
|
||||||
QVERIFY(!socket->waitForConnected(2000));
|
QVERIFY(!socket->waitForConnected(2000));
|
||||||
QVERIFY(stopWatch.elapsed() < 2000);
|
QVERIFY(stopWatch.elapsed() < 2000);
|
||||||
QCOMPARE(socket->socketError(), QAbstractSocket::SocketTimeoutError);
|
QCOMPARE(socket->error(), QAbstractSocket::SocketTimeoutError);
|
||||||
|
|
||||||
delete socket;
|
delete socket;
|
||||||
#endif
|
#endif
|
||||||
@ -2760,7 +2760,7 @@ void tst_QTcpSocket::taskQtBug5799ConnectionErrorWaitForConnected()
|
|||||||
socket.waitForConnected(10000);
|
socket.waitForConnected(10000);
|
||||||
QVERIFY2(timer.elapsed() < 9900, "Connection to closed port timed out instead of refusing, something is wrong");
|
QVERIFY2(timer.elapsed() < 9900, "Connection to closed port timed out instead of refusing, something is wrong");
|
||||||
QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!");
|
QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!");
|
||||||
QVERIFY2(socket.socketError() == QAbstractSocket::ConnectionRefusedError,
|
QVERIFY2(socket.error() == QAbstractSocket::ConnectionRefusedError,
|
||||||
QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit());
|
QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2779,7 +2779,7 @@ void tst_QTcpSocket::taskQtBug5799ConnectionErrorEventLoop()
|
|||||||
QTestEventLoop::instance().enterLoop(10);
|
QTestEventLoop::instance().enterLoop(10);
|
||||||
QVERIFY2(!QTestEventLoop::instance().timeout(), "Connection to closed port timed out instead of refusing, something is wrong");
|
QVERIFY2(!QTestEventLoop::instance().timeout(), "Connection to closed port timed out instead of refusing, something is wrong");
|
||||||
QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!");
|
QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!");
|
||||||
QVERIFY2(socket.socketError() == QAbstractSocket::ConnectionRefusedError,
|
QVERIFY2(socket.error() == QAbstractSocket::ConnectionRefusedError,
|
||||||
QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit());
|
QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2789,12 +2789,12 @@ void tst_QTcpSocket::taskQtBug7054TimeoutErrorResetting()
|
|||||||
|
|
||||||
socket->connectToHost(QtNetworkSettings::httpServerName(), 443);
|
socket->connectToHost(QtNetworkSettings::httpServerName(), 443);
|
||||||
QVERIFY(socket->waitForConnected(5*1000));
|
QVERIFY(socket->waitForConnected(5*1000));
|
||||||
QCOMPARE(socket->socketError(), QAbstractSocket::UnknownSocketError);
|
QCOMPARE(socket->error(), QAbstractSocket::UnknownSocketError);
|
||||||
|
|
||||||
// We connected to the HTTPS port. Wait two seconds to receive data. We will receive
|
// We connected to the HTTPS port. Wait two seconds to receive data. We will receive
|
||||||
// nothing because we would need to start the SSL handshake
|
// nothing because we would need to start the SSL handshake
|
||||||
QVERIFY(!socket->waitForReadyRead(2*1000));
|
QVERIFY(!socket->waitForReadyRead(2*1000));
|
||||||
QCOMPARE(socket->socketError(), QAbstractSocket::SocketTimeoutError);
|
QCOMPARE(socket->error(), QAbstractSocket::SocketTimeoutError);
|
||||||
|
|
||||||
// Now write some crap to make the server disconnect us. 4 lines are enough.
|
// Now write some crap to make the server disconnect us. 4 lines are enough.
|
||||||
socket->write("a\r\nb\r\nc\r\nd\r\n");
|
socket->write("a\r\nb\r\nc\r\nd\r\n");
|
||||||
@ -2804,7 +2804,7 @@ void tst_QTcpSocket::taskQtBug7054TimeoutErrorResetting()
|
|||||||
// should get a better error since the server disconnected us
|
// should get a better error since the server disconnected us
|
||||||
QVERIFY(!socket->waitForReadyRead(2*1000));
|
QVERIFY(!socket->waitForReadyRead(2*1000));
|
||||||
// It must NOT be the SocketTimeoutError that had been set before
|
// It must NOT be the SocketTimeoutError that had been set before
|
||||||
QCOMPARE(socket->socketError(), QAbstractSocket::RemoteHostClosedError);
|
QCOMPARE(socket->error(), QAbstractSocket::RemoteHostClosedError);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_NETWORKPROXY
|
#ifndef QT_NO_NETWORKPROXY
|
||||||
@ -2862,7 +2862,7 @@ void tst_QTcpSocket::invalidProxy()
|
|||||||
|
|
||||||
// note: the following test is not a hard failure.
|
// note: the following test is not a hard failure.
|
||||||
// Sometimes, error codes change for the better
|
// Sometimes, error codes change for the better
|
||||||
QTEST(int(socket->socketError()), "expectedError");
|
QTEST(int(socket->error()), "expectedError");
|
||||||
|
|
||||||
delete socket;
|
delete socket;
|
||||||
}
|
}
|
||||||
@ -2982,7 +2982,7 @@ void tst_QTcpSocket::proxyFactory()
|
|||||||
|
|
||||||
// note: the following test is not a hard failure.
|
// note: the following test is not a hard failure.
|
||||||
// Sometimes, error codes change for the better
|
// Sometimes, error codes change for the better
|
||||||
QTEST(int(socket->socketError()), "expectedError");
|
QTEST(int(socket->error()), "expectedError");
|
||||||
|
|
||||||
delete socket;
|
delete socket;
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ void tst_QUdpSocket::constructing()
|
|||||||
QCOMPARE(socket.canReadLine(), false);
|
QCOMPARE(socket.canReadLine(), false);
|
||||||
QCOMPARE(socket.readLine(), QByteArray());
|
QCOMPARE(socket.readLine(), QByteArray());
|
||||||
QCOMPARE(socket.socketDescriptor(), (qintptr)-1);
|
QCOMPARE(socket.socketDescriptor(), (qintptr)-1);
|
||||||
QCOMPARE(socket.socketError(), QUdpSocket::UnknownSocketError);
|
QCOMPARE(socket.error(), QUdpSocket::UnknownSocketError);
|
||||||
QCOMPARE(socket.errorString(), QString("Unknown error"));
|
QCOMPARE(socket.errorString(), QString("Unknown error"));
|
||||||
|
|
||||||
// Check the state of the socket api
|
// Check the state of the socket api
|
||||||
@ -575,7 +575,7 @@ void tst_QUdpSocket::ipv6Loop()
|
|||||||
int paulPort;
|
int paulPort;
|
||||||
|
|
||||||
if (!peter.bind(QHostAddress(QHostAddress::LocalHostIPv6), 0)) {
|
if (!peter.bind(QHostAddress(QHostAddress::LocalHostIPv6), 0)) {
|
||||||
QCOMPARE(peter.socketError(), QUdpSocket::UnsupportedSocketOperationError);
|
QCOMPARE(peter.error(), QUdpSocket::UnsupportedSocketOperationError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -897,7 +897,7 @@ void tst_QUdpSocket::writeDatagram()
|
|||||||
QCOMPARE(errorspy.count(), 1);
|
QCOMPARE(errorspy.count(), 1);
|
||||||
QCOMPARE(*static_cast<const int *>(errorspy.at(0).at(0).constData()),
|
QCOMPARE(*static_cast<const int *>(errorspy.at(0).at(0).constData()),
|
||||||
int(QUdpSocket::DatagramTooLargeError));
|
int(QUdpSocket::DatagramTooLargeError));
|
||||||
QCOMPARE(client.socketError(), QUdpSocket::DatagramTooLargeError);
|
QCOMPARE(client.error(), QUdpSocket::DatagramTooLargeError);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
QCOMPARE(bytesspy.count(), 1);
|
QCOMPARE(bytesspy.count(), 1);
|
||||||
@ -1054,14 +1054,14 @@ void tst_QUdpSocket::writeToNonExistingPeer()
|
|||||||
// the second one should fail!
|
// the second one should fail!
|
||||||
QTest::qSleep(1000); // do not process events
|
QTest::qSleep(1000); // do not process events
|
||||||
QCOMPARE(sConnected.write("", 1), qint64(-1));
|
QCOMPARE(sConnected.write("", 1), qint64(-1));
|
||||||
QCOMPARE(int(sConnected.socketError()), int(QUdpSocket::ConnectionRefusedError));
|
QCOMPARE(int(sConnected.error()), int(QUdpSocket::ConnectionRefusedError));
|
||||||
|
|
||||||
// the third one will succeed...
|
// the third one will succeed...
|
||||||
QCOMPARE(sConnected.write("", 1), qint64(1));
|
QCOMPARE(sConnected.write("", 1), qint64(1));
|
||||||
QTestEventLoop::instance().enterLoop(1);
|
QTestEventLoop::instance().enterLoop(1);
|
||||||
QCOMPARE(sConnectedReadyReadSpy.count(), 0);
|
QCOMPARE(sConnectedReadyReadSpy.count(), 0);
|
||||||
QCOMPARE(sConnectedErrorSpy.count(), 1);
|
QCOMPARE(sConnectedErrorSpy.count(), 1);
|
||||||
QCOMPARE(int(sConnected.socketError()), int(QUdpSocket::ConnectionRefusedError));
|
QCOMPARE(int(sConnected.error()), int(QUdpSocket::ConnectionRefusedError));
|
||||||
|
|
||||||
// we should now get a read error
|
// we should now get a read error
|
||||||
QCOMPARE(sConnected.write("", 1), qint64(1));
|
QCOMPARE(sConnected.write("", 1), qint64(1));
|
||||||
@ -1071,12 +1071,12 @@ void tst_QUdpSocket::writeToNonExistingPeer()
|
|||||||
QCOMPARE(sConnected.bytesAvailable(), Q_INT64_C(0));
|
QCOMPARE(sConnected.bytesAvailable(), Q_INT64_C(0));
|
||||||
QCOMPARE(sConnected.pendingDatagramSize(), Q_INT64_C(-1));
|
QCOMPARE(sConnected.pendingDatagramSize(), Q_INT64_C(-1));
|
||||||
QCOMPARE(sConnected.readDatagram(buf, 2), Q_INT64_C(-1));
|
QCOMPARE(sConnected.readDatagram(buf, 2), Q_INT64_C(-1));
|
||||||
QCOMPARE(int(sConnected.socketError()), int(QUdpSocket::ConnectionRefusedError));
|
QCOMPARE(int(sConnected.error()), int(QUdpSocket::ConnectionRefusedError));
|
||||||
|
|
||||||
QCOMPARE(sConnected.write("", 1), qint64(1));
|
QCOMPARE(sConnected.write("", 1), qint64(1));
|
||||||
QTest::qSleep(1000); // do not process events
|
QTest::qSleep(1000); // do not process events
|
||||||
QCOMPARE(sConnected.read(buf, 2), Q_INT64_C(0));
|
QCOMPARE(sConnected.read(buf, 2), Q_INT64_C(0));
|
||||||
QCOMPARE(int(sConnected.socketError()), int(QUdpSocket::ConnectionRefusedError));
|
QCOMPARE(int(sConnected.error()), int(QUdpSocket::ConnectionRefusedError));
|
||||||
|
|
||||||
// we should still be connected
|
// we should still be connected
|
||||||
QCOMPARE(int(sConnected.state()), int(QUdpSocket::ConnectedState));
|
QCOMPARE(int(sConnected.state()), int(QUdpSocket::ConnectedState));
|
||||||
|
@ -606,7 +606,7 @@ void tst_QOcsp::malformedResponse()
|
|||||||
loop.enterLoopMSecs(handshakeTimeoutMS);
|
loop.enterLoopMSecs(handshakeTimeoutMS);
|
||||||
|
|
||||||
QVERIFY(!clientSocket.isEncrypted());
|
QVERIFY(!clientSocket.isEncrypted());
|
||||||
QCOMPARE(clientSocket.socketError(), QAbstractSocket::SslHandshakeFailedError);
|
QCOMPARE(clientSocket.error(), QAbstractSocket::SslHandshakeFailedError);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QOcsp::expiredResponse_data()
|
void tst_QOcsp::expiredResponse_data()
|
||||||
|
@ -527,7 +527,7 @@ void tst_QSslSocket::constructing()
|
|||||||
QCOMPARE(socket.write(0, 0), qint64(-1));
|
QCOMPARE(socket.write(0, 0), qint64(-1));
|
||||||
QTest::ignoreMessage(QtWarningMsg, writeNotOpenMessage);
|
QTest::ignoreMessage(QtWarningMsg, writeNotOpenMessage);
|
||||||
QCOMPARE(socket.write(QByteArray()), qint64(-1));
|
QCOMPARE(socket.write(QByteArray()), qint64(-1));
|
||||||
QCOMPARE(socket.socketError(), QAbstractSocket::UnknownSocketError);
|
QCOMPARE(socket.error(), QAbstractSocket::UnknownSocketError);
|
||||||
QVERIFY(!socket.flush());
|
QVERIFY(!socket.flush());
|
||||||
QVERIFY(!socket.isValid());
|
QVERIFY(!socket.isValid());
|
||||||
QCOMPARE(socket.localAddress(), QHostAddress());
|
QCOMPARE(socket.localAddress(), QHostAddress());
|
||||||
@ -1390,16 +1390,16 @@ void tst_QSslSocket::protocolServerSide()
|
|||||||
QAbstractSocket::SocketState expectedState = (works) ? QAbstractSocket::ConnectedState : QAbstractSocket::UnconnectedState;
|
QAbstractSocket::SocketState expectedState = (works) ? QAbstractSocket::ConnectedState : QAbstractSocket::UnconnectedState;
|
||||||
// Determine whether the client or the server caused the event loop
|
// Determine whether the client or the server caused the event loop
|
||||||
// to quit due to a socket error, and investigate the culprit.
|
// to quit due to a socket error, and investigate the culprit.
|
||||||
if (client.socketError() != QAbstractSocket::UnknownSocketError) {
|
if (client.error() != QAbstractSocket::UnknownSocketError) {
|
||||||
// It can happen that the client, after TCP connection established, before
|
// It can happen that the client, after TCP connection established, before
|
||||||
// incomingConnection() slot fired, hits TLS initialization error and stops
|
// incomingConnection() slot fired, hits TLS initialization error and stops
|
||||||
// the loop, so the server socket is not created yet.
|
// the loop, so the server socket is not created yet.
|
||||||
if (server.socket)
|
if (server.socket)
|
||||||
QVERIFY(server.socket->socketError() == QAbstractSocket::UnknownSocketError);
|
QVERIFY(server.socket->error() == QAbstractSocket::UnknownSocketError);
|
||||||
|
|
||||||
QCOMPARE(client.state(), expectedState);
|
QCOMPARE(client.state(), expectedState);
|
||||||
} else if (server.socket->socketError() != QAbstractSocket::UnknownSocketError) {
|
} else if (server.socket->error() != QAbstractSocket::UnknownSocketError) {
|
||||||
QVERIFY(client.socketError() == QAbstractSocket::UnknownSocketError);
|
QVERIFY(client.error() == QAbstractSocket::UnknownSocketError);
|
||||||
QCOMPARE(server.socket->state(), expectedState);
|
QCOMPARE(server.socket->state(), expectedState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2011,7 +2011,7 @@ void tst_QSslSocket::setEmptyKey()
|
|||||||
QTestEventLoop::instance().enterLoop(2);
|
QTestEventLoop::instance().enterLoop(2);
|
||||||
|
|
||||||
QCOMPARE(socket.state(), QAbstractSocket::ConnectedState);
|
QCOMPARE(socket.state(), QAbstractSocket::ConnectedState);
|
||||||
QCOMPARE(socket.socketError(), QAbstractSocket::UnknownSocketError);
|
QCOMPARE(socket.error(), QAbstractSocket::UnknownSocketError);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QSslSocket::spontaneousWrite()
|
void tst_QSslSocket::spontaneousWrite()
|
||||||
@ -2783,11 +2783,11 @@ void tst_QSslSocket::writeBigChunk()
|
|||||||
// no better way to do this right now since the error is the same as the default error.
|
// no better way to do this right now since the error is the same as the default error.
|
||||||
if (socket->errorString().startsWith(QLatin1String("Unable to write data")))
|
if (socket->errorString().startsWith(QLatin1String("Unable to write data")))
|
||||||
{
|
{
|
||||||
qWarning() << socket->socketError() << socket->errorString();
|
qWarning() << socket->error() << socket->errorString();
|
||||||
QFAIL("Error while writing! Check if the OpenSSL BIO size is limited?!");
|
QFAIL("Error while writing! Check if the OpenSSL BIO size is limited?!");
|
||||||
}
|
}
|
||||||
// also check the error string. If another error (than UnknownError) occurred, it should be different than before
|
// also check the error string. If another error (than UnknownError) occurred, it should be different than before
|
||||||
QVERIFY2(errorBefore == errorAfter || socket->socketError() == QAbstractSocket::RemoteHostClosedError,
|
QVERIFY2(errorBefore == errorAfter || socket->error() == QAbstractSocket::RemoteHostClosedError,
|
||||||
QByteArray("unexpected error: ").append(qPrintable(errorAfter)));
|
QByteArray("unexpected error: ").append(qPrintable(errorAfter)));
|
||||||
|
|
||||||
// check that everything has been written to OpenSSL
|
// check that everything has been written to OpenSSL
|
||||||
@ -2982,7 +2982,7 @@ void tst_QSslSocket::resume()
|
|||||||
QCOMPARE(encryptedSpy.count(), 0);
|
QCOMPARE(encryptedSpy.count(), 0);
|
||||||
QVERIFY(!socket.isEncrypted());
|
QVERIFY(!socket.isEncrypted());
|
||||||
QCOMPARE(errorSpy.count(), 1);
|
QCOMPARE(errorSpy.count(), 1);
|
||||||
QCOMPARE(socket.socketError(), QAbstractSocket::SslHandshakeFailedError);
|
QCOMPARE(socket.error(), QAbstractSocket::SslHandshakeFailedError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4347,9 +4347,9 @@ void tst_QSslSocket::disabledProtocols()
|
|||||||
// early, preventing any real connection from ever starting.
|
// early, preventing any real connection from ever starting.
|
||||||
QSslSocket socket;
|
QSslSocket socket;
|
||||||
socket.setProtocol(disabledProtocol);
|
socket.setProtocol(disabledProtocol);
|
||||||
QCOMPARE(socket.socketError(), QAbstractSocket::UnknownSocketError);
|
QCOMPARE(socket.error(), QAbstractSocket::UnknownSocketError);
|
||||||
socket.connectToHostEncrypted(QStringLiteral("doesnotmatter.org"), 1010);
|
socket.connectToHostEncrypted(QStringLiteral("doesnotmatter.org"), 1010);
|
||||||
QCOMPARE(socket.socketError(), QAbstractSocket::SslInvalidUserDataError);
|
QCOMPARE(socket.error(), QAbstractSocket::SslInvalidUserDataError);
|
||||||
QCOMPARE(socket.state(), QAbstractSocket::UnconnectedState);
|
QCOMPARE(socket.state(), QAbstractSocket::UnconnectedState);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -4359,14 +4359,14 @@ void tst_QSslSocket::disabledProtocols()
|
|||||||
QVERIFY(server.listen());
|
QVERIFY(server.listen());
|
||||||
|
|
||||||
QSslSocket socket;
|
QSslSocket socket;
|
||||||
QCOMPARE(socket.socketError(), QAbstractSocket::UnknownSocketError);
|
QCOMPARE(socket.error(), QAbstractSocket::UnknownSocketError);
|
||||||
|
|
||||||
socket.connectToHost(QHostAddress::LocalHost, server.serverPort());
|
socket.connectToHost(QHostAddress::LocalHost, server.serverPort());
|
||||||
QVERIFY(socket.waitForConnected(timeoutMS));
|
QVERIFY(socket.waitForConnected(timeoutMS));
|
||||||
|
|
||||||
socket.setProtocol(disabledProtocol);
|
socket.setProtocol(disabledProtocol);
|
||||||
socket.startClientEncryption();
|
socket.startClientEncryption();
|
||||||
QCOMPARE(socket.socketError(), QAbstractSocket::SslInvalidUserDataError);
|
QCOMPARE(socket.error(), QAbstractSocket::SslInvalidUserDataError);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// 2. waitForEncrypted: client-side, blocking API plus requires from us
|
// 2. waitForEncrypted: client-side, blocking API plus requires from us
|
||||||
@ -4390,7 +4390,7 @@ void tst_QSslSocket::disabledProtocols()
|
|||||||
loop.enterLoopMSecs(timeoutMS);
|
loop.enterLoopMSecs(timeoutMS);
|
||||||
QVERIFY(!loop.timeout());
|
QVERIFY(!loop.timeout());
|
||||||
QVERIFY(server.socket);
|
QVERIFY(server.socket);
|
||||||
QCOMPARE(server.socket->socketError(), QAbstractSocket::SslInvalidUserDataError);
|
QCOMPARE(server.socket->error(), QAbstractSocket::SslInvalidUserDataError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,7 +428,7 @@ void tst_NetworkSelfTest::serverReachability()
|
|||||||
QVERIFY2(timer.elapsed() < 9900, "Connection to closed port timed out instead of refusing, something is wrong");
|
QVERIFY2(timer.elapsed() < 9900, "Connection to closed port timed out instead of refusing, something is wrong");
|
||||||
|
|
||||||
QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!");
|
QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!");
|
||||||
QVERIFY2(socket.socketError() == QAbstractSocket::ConnectionRefusedError,
|
QVERIFY2(socket.error() == QAbstractSocket::ConnectionRefusedError,
|
||||||
QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit());
|
QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,7 +458,7 @@ void tst_NetworkSelfTest::remotePortsOpen()
|
|||||||
socket.connectToHost(QtNetworkSettings::serverName(), portNumber);
|
socket.connectToHost(QtNetworkSettings::serverName(), portNumber);
|
||||||
|
|
||||||
if (!socket.waitForConnected(10000)) {
|
if (!socket.waitForConnected(10000)) {
|
||||||
if (socket.socketError() == QAbstractSocket::SocketTimeoutError)
|
if (socket.error() == QAbstractSocket::SocketTimeoutError)
|
||||||
QFAIL(QString("Network timeout connecting to the server on port %1").arg(portNumber).toLocal8Bit());
|
QFAIL(QString("Network timeout connecting to the server on port %1").arg(portNumber).toLocal8Bit());
|
||||||
else
|
else
|
||||||
QFAIL(QString("Error connecting to server on port %1: %2").arg(portNumber).arg(socket.errorString()).toLocal8Bit());
|
QFAIL(QString("Error connecting to server on port %1: %2").arg(portNumber).arg(socket.errorString()).toLocal8Bit());
|
||||||
|
@ -545,7 +545,7 @@ bool BaselineProtocol::receiveBlock(Command *cmd, QByteArray *block)
|
|||||||
QString BaselineProtocol::errorMessage()
|
QString BaselineProtocol::errorMessage()
|
||||||
{
|
{
|
||||||
QString ret = errMsg;
|
QString ret = errMsg;
|
||||||
if (socket.socketError() >= 0)
|
if (socket.error() >= 0)
|
||||||
ret += QLS(" Socket state: ") + socket.errorString();
|
ret += QLS(" Socket state: ") + socket.errorString();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user