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 508 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 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?

    sierdzioS 1 Reply Last reply
    0
    • T Taytoo

      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?

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on 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

      • Login

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