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. How to check Ethernet port connection status in Qt?
QtWS25 Last Chance

How to check Ethernet port connection status in Qt?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtcreatorethernet in qtudp protocolqml
6 Posts 2 Posters 2.4k Views
  • 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.
  • I Offline
    I Offline
    im_vidhya
    wrote on last edited by
    #1

    Hi everyone,
    I am new to Qt .Actually, i want to check Whether the Ethernet is connected or not through qt application.
    For Example: when the Data is transfer from source to Destination through Ethernet. if i suddenly, remove the Ethernet cable my Qt application has to give some pop-up message like "the connection is unavailable". Is there any way to find this one? Finally,Sorry for my English.

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      How are you transferring the data ? Are you using the sockets ? If ethernet is removed, you will get the connection reset error at socket end point. Based on this you should be able to show some error message to user.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      I 1 Reply Last reply
      2
      • dheerendraD dheerendra

        How are you transferring the data ? Are you using the sockets ? If ethernet is removed, you will get the connection reset error at socket end point. Based on this you should be able to show some error message to user.

        I Offline
        I Offline
        im_vidhya
        wrote on last edited by
        #3

        @dheerendra Thankyou for your reply sir. Yes i created sockets . Actually i'm using udp communication. my exact doubt is while data is transferring through Ethernet . if i suddenly remove the ethernet cable . Which signal will generate in Qt?

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          If it UDP, it difficult. Error can happen only if you try to write a data. Try catching the error() or disconnected() signals from UDP.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          I 1 Reply Last reply
          1
          • dheerendraD dheerendra

            If it UDP, it difficult. Error can happen only if you try to write a data. Try catching the error() or disconnected() signals from UDP.

            I Offline
            I Offline
            im_vidhya
            wrote on last edited by
            #5

            @dheerendra I tried sir. when i send data using QUdpSocket::writedatagram function even ethernet connection is not there also this function(writedatagram) return success only.

            1 Reply Last reply
            0
            • dheerendraD Offline
              dheerendraD Offline
              dheerendra
              Qt Champions 2022
              wrote on last edited by
              #6

              As I said earlier, very difficult to get the status ethernet using UDP. UDP is fire & forget protocol. You need to build your own mechanism to monitor the status. It could be simple TCP connection to see if the connection alive with remote server. If not you need to get the interfaces status periodically through QNetworkInterface & check if the interface is up. You can use QNetworkInterface::flags() & QNetworkInterface::IsUp to check the status.

              Dheerendra
              @Community Service
              Certified Qt Specialist
              http://www.pthinks.com

              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