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. QTcpSocket & livetime & deletion
QtWS25 Last Chance

QTcpSocket & livetime & deletion

Scheduled Pinned Locked Moved Solved General and Desktop
qtcpsocketqtcpserver
4 Posts 3 Posters 787 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.
  • D Offline
    D Offline
    Dariusz
    wrote on 9 May 2021, 22:31 last edited by
    #1

    Hey!

    2 Cases
    QTcpSocket = QTcpSocket::connectToHost()
    and QTcpServer : nextPendingConnection()
    Both of them are sockets with conections.
    The question I have... if I deleteLater() the sockets, do the connection get automatically disconnected, or do they remain active?

    Secondly if I set option, QAbstractSocket::KeepAliveOption, does the connection then remain active after I delete socket?

    Just trying to understand some odd cases where I delete socket and my server/client still remains connected...

    TIA

    J 1 Reply Last reply 10 May 2021, 06:18
    0
    • D Dariusz
      9 May 2021, 22:31

      Hey!

      2 Cases
      QTcpSocket = QTcpSocket::connectToHost()
      and QTcpServer : nextPendingConnection()
      Both of them are sockets with conections.
      The question I have... if I deleteLater() the sockets, do the connection get automatically disconnected, or do they remain active?

      Secondly if I set option, QAbstractSocket::KeepAliveOption, does the connection then remain active after I delete socket?

      Just trying to understand some odd cases where I delete socket and my server/client still remains connected...

      TIA

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 10 May 2021, 06:18 last edited by
      #3

      @Dariusz said in QTcpSocket & livetime & deletion:

      if I deleteLater() the sockets, do the connection get automatically disconnected, or do they remain active?

      https://doc.qt.io/qt-5/qtcpsocket.html#dtor.QTcpSocket

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

      D 1 Reply Last reply 10 May 2021, 06:58
      0
      • K Offline
        K Offline
        Kent-Dorfman
        wrote on 10 May 2021, 02:12 last edited by
        #2

        TCP will disconnect after a standard timout in lieu of an explicit close. setsockopt() can set the timeout.

        1 Reply Last reply
        0
        • D Dariusz
          9 May 2021, 22:31

          Hey!

          2 Cases
          QTcpSocket = QTcpSocket::connectToHost()
          and QTcpServer : nextPendingConnection()
          Both of them are sockets with conections.
          The question I have... if I deleteLater() the sockets, do the connection get automatically disconnected, or do they remain active?

          Secondly if I set option, QAbstractSocket::KeepAliveOption, does the connection then remain active after I delete socket?

          Just trying to understand some odd cases where I delete socket and my server/client still remains connected...

          TIA

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 10 May 2021, 06:18 last edited by
          #3

          @Dariusz said in QTcpSocket & livetime & deletion:

          if I deleteLater() the sockets, do the connection get automatically disconnected, or do they remain active?

          https://doc.qt.io/qt-5/qtcpsocket.html#dtor.QTcpSocket

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

          D 1 Reply Last reply 10 May 2021, 06:58
          0
          • J jsulm
            10 May 2021, 06:18

            @Dariusz said in QTcpSocket & livetime & deletion:

            if I deleteLater() the sockets, do the connection get automatically disconnected, or do they remain active?

            https://doc.qt.io/qt-5/qtcpsocket.html#dtor.QTcpSocket

            D Offline
            D Offline
            Dariusz
            wrote on 10 May 2021, 06:58 last edited by
            #4

            @jsulm Silly me, I always went straight to QAbstractSocket from that page... thanks!

            1 Reply Last reply
            0

            4/4

            10 May 2021, 06:58

            • Login

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