Results 1 to 18 of 18

Thread: QNetworkReply: how to know when data is sent?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QNetworkReply: how to know when data is sent?

    QHttp should work fine. It has a dataSendProgress() signal.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Re: QNetworkReply: how to know when data is sent?

    Ok, i thought to use it from the very beginning, I didn't just because I read the following in the Qt documentation: "This class is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code."

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QNetworkReply: how to know when data is sent?

    Yes, that's true but your requirement is somewhat different from what people use HTTP for in their apps. I don't know why you don't want to wait for the server's response -- you might get a 404 or 500 or some other fault. I think it's worth knowing if your request went to /dev/null or not.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Re: QNetworkReply: how to know when data is sent?

    I may want to upload some data or send logout. Sometimes it takes a several seconds (depending on connection, network problems etc). In my application it is more important to proceed quickly than know whether the data was uploaded or not. I don't care much how successful was logout sent to some third party server, but I want my app to be closed quickly, so users won't need to wait until slow server responds.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QNetworkReply: how to know when data is sent?

    So why do you want to send the logout at all if you don't care if it works or not?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Re: QNetworkReply: how to know when data is sent?

    I send logout because it is better to send than not to send (third party server recommends to send it). Also I upload some data that may be useful, but if it fails it is not critical. Moreover if logout fails in most cases I can't do anything with that, so result can be only logged somewhere and it is not that important for users. But as long as it doesn't make my application inconvenient to users I think it is better to call logout and upload all the data that may be useful.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QNetworkReply: how to know when data is sent?

    Then don't wait for anything, send the data and start closing your app. With a bit of luck, the request will go through. If not then you don't care anyway... If you do care, then wait a predefined amount of time for a response and if you don't get it during this period, abandon the request and close your app.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Re: QNetworkReply: how to know when data is sent?

    Well, eventually I came to the same approach. I can afford it to wait for let's say 1 second, the only bad side is that waiting for data sent in most cases would take less time, but with this approach I still have to wait 1 second that is for the worst case. My question: is there any place where I can ask to add this feature? To my mind having dataSent signal would be useful.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QNetworkReply: how to know when data is sent?

    Qt is open-source, add the feature yourself. It should be just a couple lines of code.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 1
    Last Post: 8th March 2011, 06:27
  2. Subclassing QNetworkReply
    By piotr.dobrogost in forum Qt Programming
    Replies: 6
    Last Post: 19th December 2010, 08:42
  3. Cannot get QNetworkCookie from QNetworkReply
    By MorrisLiang in forum Newbie
    Replies: 1
    Last Post: 25th May 2010, 16:59
  4. QNetworkReply::HostNotFoundError
    By timmu in forum Qt Programming
    Replies: 1
    Last Post: 25th August 2009, 10:58
  5. When to delete QNetworkReply?
    By QPlace in forum Qt Programming
    Replies: 5
    Last Post: 11th February 2009, 12:46

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.