开发者

QAbstractSocket::UnknownSocketError

What could be cause of QAbstractSocket::UnknownSocketError when using QTcpSocket?


CODE

I'm getting this error code with the following code:

this->connect(socket, SIGNAL(socketError(QAbstractSocket::SocketError)), SLOT(handleSocketError(QAbstractSocket::SocketError)));
...
void MyClass::handleSocketError(QAbstractSocket::SocketError error)
{
    qDebug() << error;
}

MORE INF开发者_开发问答O

The QTcpSocket is trying to connect to some remote host. And it fails with mentioned error code.


If you read the code, you'll see that this error means exactly what it says: "something bad happened and I don't know why". There had to be exceptions, of course:

  • The socket is not connected to a server and you try to write to it (src/network/socket/qabstractsocket.cpp on line 2025)
  • An SSL error occurred (src/network/ssl/qsslsocket_openssl.cpp in a lot of places)

In both situations the errorString is set to an appropriate message.


Possibly you called the error() function when there is no error.


Looking for AbstractSocketError in the Qt sources gives quite some hits. Maybe fire up a debugger and look into the backtrace when you get the error() signal. Possibly an exotic error condition occured in the underlying socket engine (which is a Qt internal class).


Does remote host require ssl connection? It may be problem if your Qt copy can't load libssl. I had same problem (UnkownSocketError) when Qt couldn't find libssl

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜