Qt 4.6.4: QNetworkAccessManager cannot close the connection



  • Hi,

    I'm developing an application in qt4.6.4 for symbian 5.2 which uses QNetworkAccessManager for HTTP communication.

    I'm facing a problem that connection is left open after usage, even QNetworkAccessManager and QNetworkReply class instances are deleted. I spent quite a lot time by trying different ways of delete instances, but nothing helps.
    However, connection is closed when application is exited.

    Has anyone faced same problem?
    Is there any way to close network connection by using those classes?

    I know connection can be closed by using QNetworkSession but in our environment
    it is still part of qt mobility api and we cannot take it into the use.

    @
    void webclient::go()
    {
    if (m_manager == NULL)
    {
    m_manager = new QNetworkAccessManager(this);

    }
    m_reply = m_manager->get(QNetworkRequest(QUrl("http://qt.nokia.com")));
        connect(m_manager, SIGNAL(finished(QNetworkReply*)),
                this, SLOT(handleFinished(QNetworkReply*)));
    

    }

    void webclient::handleFinished(QNetworkReply *reply)
    {
    //m_reply->deleteLater(); //this is also tried, and many other ways too..

    delete m_reply;
    m_reply = NULL;
    delete m_manager;
    m_manager = NULL;
    

    }
    @

    br,
    jonexi

    [edit: code highlighted / Denis Kormalev]



  • As far as I know, it is not possible to close the connection without QNetworkSession. QNetworkAccessManager does not give you this option in Qt 4.6. In Qt 4.7 it is possible, I think.



  • hi, did you confirm that the handleFinished() slot was called ... there if you call the close() on m_reply, that should free the resources


Log in to reply
 

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