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. What does QAbstractSocket::KeepAliveOption actually do?
Forum Update on Monday, May 27th 2025

What does QAbstractSocket::KeepAliveOption actually do?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 2.9k 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.
  • V Offline
    V Offline
    Vadi2
    wrote on last edited by Vadi2
    #1

    The documentation is a bit unclear, but if I enable QAbstractSocket::KeepAliveOption on a TCP socket, will it automatically send the keepalive packets for me?

    raven-worxR 1 Reply Last reply
    0
    • V Vadi2

      The documentation is a bit unclear, but if I enable QAbstractSocket::KeepAliveOption on a TCP socket, will it automatically send the keepalive packets for me?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Vadi2
      as the docs also state it sets the SO_KEEPALIVE option on the underlying platform socket.
      So you should look up this option for your target platform.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • V Offline
        V Offline
        Vadi2
        wrote on last edited by
        #3

        What does that practically mean on Windows/Linux/macOS?

        raven-worxR JonBJ 2 Replies Last reply
        0
        • V Vadi2

          What does that practically mean on Windows/Linux/macOS?

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by raven-worx
          #4

          @Vadi2
          Windows, Linux
          the principle should be the same on all platforms (for TCP)

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • V Vadi2

            What does that practically mean on Windows/Linux/macOS?

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @Vadi2
            Behaviour of SO_KEEPALIVE varies enormously between various OSes, different TCP stacks, etc. You really do have to do a lot of reading (e.g. @raven-worx's link, stackoverflow etc.) if you really know what it might or might not do.

            My experience (maybe a bit old now)? Don't rely on it to do anything.

            Or, in particular: I used to use to (try to) keep a connection from timing out. In practice, far from that, what it actually did was: caused my app to notice that a connection had become lost, and so complain, when had I not used it then the app wouldn't have noticed a lost connection till I sent/received, and by then might have silently re-established the connection without complaint. So I gave up on it!

            1 Reply Last reply
            0

            • Login

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