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. Appropriate API for detecting network status change
Forum Updated to NodeBB v4.3 + New Features

Appropriate API for detecting network status change

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 530 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.
  • T Offline
    T Offline
    Taytoo
    wrote on 3 Apr 2020, 15:38 last edited by
    #1

    Trying to figure out how to get notified of Internet availability after disconnection. According to the documentation there are multiple potential APIs:

    1. QNetworkSession::stateChanged()
    2. QNetworkAccessManager::networkAccessibleChanged()
    3. QNetworkConfigurationManager::onlineStateChanged()

    onlineStateChanged, basically just checks all network interfaces if they are Up or not and if any of them is working, then it returns true. The problem is that if wifi/lan is connected but ISP/internet is down OR wifi/lan is disconnected but a virtual interface (typically created by VMs) is active. In these cases it still returns true/online.

    I'm not 100% sure about 1 & 2. Can anyone briefly explain the differences between these APIs and use cases? Is there an API that notifies when Internet becomes (un)available?

    S 1 Reply Last reply 3 Apr 2020, 18:17
    0
    • T Taytoo
      3 Apr 2020, 15:38

      Trying to figure out how to get notified of Internet availability after disconnection. According to the documentation there are multiple potential APIs:

      1. QNetworkSession::stateChanged()
      2. QNetworkAccessManager::networkAccessibleChanged()
      3. QNetworkConfigurationManager::onlineStateChanged()

      onlineStateChanged, basically just checks all network interfaces if they are Up or not and if any of them is working, then it returns true. The problem is that if wifi/lan is connected but ISP/internet is down OR wifi/lan is disconnected but a virtual interface (typically created by VMs) is active. In these cases it still returns true/online.

      I'm not 100% sure about 1 & 2. Can anyone briefly explain the differences between these APIs and use cases? Is there an API that notifies when Internet becomes (un)available?

      S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 3 Apr 2020, 18:17 last edited by
      #2

      @Taytoo said in Appropriate API for detecting network status change:

      Is there an API that notifies when Internet becomes (un)available?

      There is no such API in Qt. If you want to check, periodically ping some well-known host (your server or google.com etc.). There are some native APIs for detecting Internet access, for example on Android. But there is no common API for all systems (at least in Qt).

      (Z(:^

      1 Reply Last reply
      1

      1/2

      3 Apr 2020, 15:38

      • Login

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