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. Get/Check Windows Keepalive event
Forum Updated to NodeBB v4.3 + New Features

Get/Check Windows Keepalive event

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 4 Posters 3.3k Views 2 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.
  • divergerD Offline
    divergerD Offline
    diverger
    wrote on last edited by diverger
    #1

    I want to use "Keepalive" message to check if the net connection are good or not. That is, If there are no ACKs returned from the remote for the 'Keepalive' meeages I sent, I will assume the link may broken. But how I got the event, or what APIs I should call to check it?

    jsulmJ 1 Reply Last reply
    0
    • divergerD diverger

      I want to use "Keepalive" message to check if the net connection are good or not. That is, If there are no ACKs returned from the remote for the 'Keepalive' meeages I sent, I will assume the link may broken. But how I got the event, or what APIs I should call to check it?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @diverger What are you talking about? Some win32 API messages? Networking?
      "check if the net connection are good or not" - what kind of connection do you mean?
      If it is a network connection then take a look at http://doc.qt.io/qt-5/qtnetwork-index.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      divergerD 1 Reply Last reply
      0
      • divergerD Offline
        divergerD Offline
        diverger
        wrote on last edited by diverger
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • jsulmJ jsulm

          @diverger What are you talking about? Some win32 API messages? Networking?
          "check if the net connection are good or not" - what kind of connection do you mean?
          If it is a network connection then take a look at http://doc.qt.io/qt-5/qtnetwork-index.html

          divergerD Offline
          divergerD Offline
          diverger
          wrote on last edited by
          #4

          @jsulm I use QTcpSocket to communicate with a remote host. The connection may sometimes lost due to some reasons, such as cable un-plugged, or cable broken. So I try to enable 'Keepalive' socket options to make the app aware this. IMHO, when the OS send some keepalive probes and receive no ACKs, then it should think the connection is lost. But how can my app know this? Does Qt have some slots to receive this event information? Or I should call some Qt's functions or Windows API to query this information?

          jsulmJ 2 Replies Last reply
          0
          • divergerD diverger

            @jsulm I use QTcpSocket to communicate with a remote host. The connection may sometimes lost due to some reasons, such as cable un-plugged, or cable broken. So I try to enable 'Keepalive' socket options to make the app aware this. IMHO, when the OS send some keepalive probes and receive no ACKs, then it should think the connection is lost. But how can my app know this? Does Qt have some slots to receive this event information? Or I should call some Qt's functions or Windows API to query this information?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @diverger Since you're using QTcpSocket you can check its documentation:
            http://doc.qt.io/qt-5/qabstractsocket.html#disconnected
            and
            http://doc.qt.io/qt-5/qabstractsocket.html#error-1
            and
            http://doc.qt.io/qt-5/qabstractsocket.html#stateChanged

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • divergerD diverger

              @jsulm I use QTcpSocket to communicate with a remote host. The connection may sometimes lost due to some reasons, such as cable un-plugged, or cable broken. So I try to enable 'Keepalive' socket options to make the app aware this. IMHO, when the OS send some keepalive probes and receive no ACKs, then it should think the connection is lost. But how can my app know this? Does Qt have some slots to receive this event information? Or I should call some Qt's functions or Windows API to query this information?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @diverger said in Get/Check Windows Keepalive event:

              OS send some keepalive probes

              There is no such thing. But you will be notified if your socket gets disconnected. Just connect slots to the signals I mentioned before.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              divergerD 1 Reply Last reply
              0
              • jsulmJ jsulm

                @diverger said in Get/Check Windows Keepalive event:

                OS send some keepalive probes

                There is no such thing. But you will be notified if your socket gets disconnected. Just connect slots to the signals I mentioned before.

                divergerD Offline
                divergerD Offline
                diverger
                wrote on last edited by diverger
                #7

                @jsulm You mean when OS's keepalive probes are not responded by the remote, it will issue errors to the socket? Ok, I'll give a try. Thanks.

                jsulmJ kshegunovK 2 Replies Last reply
                0
                • divergerD diverger

                  @jsulm You mean when OS's keepalive probes are not responded by the remote, it will issue errors to the socket? Ok, I'll give a try. Thanks.

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @diverger said in Get/Check Windows Keepalive event:

                  OS's keepalive probes

                  What are "OS's keepalive probes"? There is no such thing to my knowledge.
                  If the connection is lost you will get disconnected signal and socket state will change.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  divergerD 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @diverger said in Get/Check Windows Keepalive event:

                    OS's keepalive probes

                    What are "OS's keepalive probes"? There is no such thing to my knowledge.
                    If the connection is lost you will get disconnected signal and socket state will change.

                    divergerD Offline
                    divergerD Offline
                    diverger
                    wrote on last edited by
                    #9

                    @jsulm Windows call the keepalive messages as " keep-alive probes", just the empty ACKs.

                    1 Reply Last reply
                    1
                    • mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by mrjj
                      #10

                      Hi
                      I never heard about that before. :)
                      Sounds pretty useful.
                      https://blogs.technet.microsoft.com/nettracer/2010/06/03/things-that-you-may-want-to-know-about-tcp-keepalives/

                      1 Reply Last reply
                      0
                      • divergerD diverger

                        @jsulm You mean when OS's keepalive probes are not responded by the remote, it will issue errors to the socket? Ok, I'll give a try. Thanks.

                        kshegunovK Offline
                        kshegunovK Offline
                        kshegunov
                        Moderators
                        wrote on last edited by
                        #11

                        http://doc.qt.io/qt-5/qabstractsocket.html#SocketOption-enum

                        But bear in mind the keep-alive mechanism is low-level. You can't manipulate it, you'll just get your connection dropped if an ACK package times out.

                        Read and abide by the Qt Code of Conduct

                        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