Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Detecting when network connection is lost
Forum Updated to NodeBB v4.3 + New Features

Detecting when network connection is lost

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kloveridge
    wrote on last edited by
    #1

    I am writing a simple FTP downloader. Despite the recommendation of not using QFtp (because its deprecated), I am proceeding to use it anyway. Its a little annoying that Qt would deprecate this without providing a new version. But whatever.

    So far, I can log in. Get a list of files. Etc. Everything works pretty good. The one thing that is unclear is how do I detect if I've lost my connection with the ftp site?

    I have a QTimer that will timeout if the initial login fails within a few seconds. But suppose I log in. And I send a request to download a file. How can I check if the ftp connection is valid before sending the request? How about in the middle of the download? How do I detect if there is a lost connection?

    Any suggestions would be appreciated.

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      I don't think there's a way to tell if connection is valid before you use it (apart from the state() function).
      But you can just try to send a command (or sequence) anyway. Whenever a sequence finishes QFtp sends a done(bool error) signal. If there was interruption, connection lost or any other kind of error the error flag will be true.
      You can then proceed with error() or errorString() to see what kind of error occurred.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sirch
        wrote on last edited by
        #3

        SIGNAL stateChanged(int state)

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved