QTcpSocket internal buffer



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



  • 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 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()?



  • 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.



  • 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?



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.