title: Checking internet connectivity using QtNetwork and PyQt5
body: <p>I'm trying to check network connectivity the hard way using <code>QtNetwork</code> but can't figure out how to do it properly. This is the code I'm working on it seems that neither <code>finished</code> nor <code>error</code> signals are called. What I'm missing here?</p>
  
  <pre><code>import sys
  from PyQt5 import QtCore, QtNetwork, QtWidgets
  
  
  class CheckConnectivity:
      def __init__(self):
          url = QtCore.QUrl("https://www.google.com/")
          req = QtNetwork.QNetworkRequest(url)
          net_manager = QtNetwork.QNetworkAccessManager()
          self.res = net_manager.get(req)
          self.res.finished.connect(self.processRes)
          self.res.error.connect(self.processErr)
          self.msg = QtWidgets.QMessageBox()
  
      def processRes(self):
          if self.res.bytesAvailable():
              self.msg.information(self, "Info", "You are connected to the Internet.")
          else:
              self.msg.critical(self, "Info", "You are not connected to the Internet.")
          self.msg.show()
          self.res.close()
  
      def processErr(self, *args):
          print(*args)
  
  
  if __name__ == "__main__":
      app = QtWidgets.QApplication(sys.argv)
      ic = CheckConnectivity()
      sys.exit(app.exec_())
  </code></pre>