Cant connect to a Server

  • I have a QTcpServer that is listening, when i start him. I checked my System and he listens on localhost on port 6111. In my Server i have overwritten the incomingConnection Function. But i cant connect with my Client. My Client always says this QSslSocket: cannot resolve SSLv3_client_method QSslSocket: cannot resolve SSLv3_server_method
    QObject::connect: Cannot connect (null)::destroyed() to QHostInfoLookupManager::waitForThreadPoolDone()
    "Network operation timed out"

    I use QSslSocket and for testing i have insert a qDebug() << "connection"; to my incomingConnection function that i have overwritten. So the Problem is maybe that the Server is not getting any Connection from my Client. Anyone has some Ideas? If more Informations are necessary please ask.

    Dont know where i start to find the Error. As i said my Server is listening, but i cant go for a connection.

  • Lifetime Qt Champion

    Can be bug
    Can be bug in your code

    We need more information to give any guesses.

    Like platform. Qt version and maybe some code.

    Also, the server and client RUNS on same machine, correct?

  • Both Programs are running on the same Machine. I use Manjaro based on Arch Linux with KDE. edit: I forgot to say that im using 5.7

    My Server Class

    void Server::start()
        if (this->listen(QHostAddress::LocalHost, 6111))
            qDebug() << "Server started!";
            qDebug() << "Server couldnt get started!";
    void Server::incomingConnection(int socketDescriptor)
        qDebug() << "Incoming Connection";
        QScopedPointer<ConnectionThread> thread(new ConnectionThread(socketDescriptor, this));
        connect(, SIGNAL(finished()),, SLOT(deleteLater()));

    The QThread Class (only the importan Parts)

    void ConnectionThread::run()
        _socket.reset(new QSslSocket());
        if (!_socket->setSocketDescriptor(this->_socketDescriptor))
            emit error(_socket->error());
        connect(, SIGNAL(readyRead()), this, SLOT(handleConnection()));
        connect(, SIGNAL(disconnected()), this, SLOT(disconnected()));
        connect(, SIGNAL(sslErrors(const QList &)), this, SLOT(errorSsl(QList)));
    void ConnectionThread::handleConnection()
        if (_socket->waitForEncrypted())
            QScopedPointer<User> user(new User());
            if (_socket->waitForReadyRead())
                QString line = _socket->readAll();
                QByteArray bytes;
                if (_socket->waitForBytesWritten())

    And my Client Connection function

    void Network::sendData( const QString &data, QString *response)
        QScopedPointer<QSslSocket> socket(new QSslSocket());
        socket->connectToHostEncrypted(HOST, PORT);
        QList<QSslError> errors = socket->sslErrors();
        for (int i = 0; i < errors.size(); ++i)
            qDebug() <<;
        if (socket->waitForEncrypted())
            QByteArray bytes;
            if (socket->waitForBytesWritten())
                if (socket->waitForReadyRead())
                    *response = socket->readAll();
                    if (socket->disconnect())
                    *response = socket->errorString();
                *response = socket->errorString();
            *response = socket->errorString();

    I dont understand why my Server dont ouput this qDebug() << "Incoming Connection"; . I guess there is no incoming Connection, but i dont know why.

  • Hi,

    To answer your question about why your server isn't printing "incoming connection".
    I think you're not correctly overriding the virtual protected incomingConnection function. Your function signature differs from the one of QTcpServer, check out:
    You're using an int but it should be a qintptr instead.

    About the SSL problems:

    • do you have OpenSSL installed on your system?
    • what version of OpenSSL are you using? I'm not sure when but lately OpenSSL changed some things which could result in the error(s) you've.

  • Wow nice. You was right. I read the documentaion then i searched a Tutorial and in the Tutorial they used int instead of qintptr.

    The Solution was

    void incomingConnection(qintptr socketDescriptor);

    Thx again.

  • Qt Champions 2018

    There is so much wrong I don't know where to start. As mentioned above the signature is wrong, use Q_DECL_OVERRIDE to spot these mistakes

    • The lifecycle of variables is wrong (QScopedPointer deletes everything when it goes out of scope)
    • some connections are wrong ( SIGNAL(sslErrors(const QList &)) missing template parameter)
    • after socket->connectToHostEncrypted(HOST, PORT); you do not wait for connected
    • socket->disconnect() does not do what you think it does (that disconnects signals and slots, not the network)
    • waitForReadyRead() waits untill some data can be read, there is no assurance all data can be read
    • QString line = _socket->readAll(); and bytes.append(data); does not support unicode (you should use QDataStream)
    • There is no way I can see to stop the thread


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.