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 internal buffer
Qt 6.11 is out! See what's new in the release blog

QTcpSocket internal buffer

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.0k Views 1 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.
  • J Offline
    J Offline
    Jyang772
    wrote on last edited by
    #1

    Is QTcpSocket's internal buffer cleared when close() is called?

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

      Hope you are asking about internal socket buffer. When the close issued, all the segments preceding the current close request will sent to remote end. Hope that's what you are asking here. Please note Qt may not have any role to play when close is issued. It may just call close of the socket end point.

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

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jyang772
        wrote on last edited by
        #3

        [quote author="Dheerendra" date="1408776187"]Hope you are asking about internal socket buffer. When the close issued, all the segments preceding the current close request will sent to remote end. Hope that's what you are asking here. Please note Qt may not have any role to play when close is issued. It may just call close of the socket end point.[/quote]

        Yes, sorry. That's what I meant.
        What do you mean by "all the segments preceding the current close request will sent to remote end"?

        And does this have anything to do with why QTcpSocket::size() becomes 0 after I call close()?

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

          Once socket close is issued, close segment is sent to peer end-point. It means to indicate that this side has no data to send. At the same time other endpoint also has to issue close if it does not want to send the data.

          Preceding current close means that what ever the data segments you put before the socket close should be delivered to remote-end.

          If you are seeing size as zero means that there is not data from the other end. It is nothing to do with close issued from this end.

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

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jyang772
            wrote on last edited by
            #5

            Okay, so what clears the internal buffer so that when I create a new connection old data isn't read again? Or does the old data get overwritten.

            If I used readAll(), all of the data in the buffer and the buffer is cleared. Is this what is happening?

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

              What do you mean by newConnection ? Is it the same client with same port# to server with same port# ? This can't happen immediately. There is time duration(MST) defined by TCP before which TCP will not allow same connection. After this old data will not have any relevance and gets discarded.

              Yes readAll reads all data and clears everything.

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

              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