[Solved] QTcpSocket - Very Fast Transfer



  • I have an external program (using WinSocket) that sends data to my Qt server program. The client is sending data packets very quickly after each other (in a loop). Now the problem seems that my Qt server is not getting all the data, or at least the readyRead() signal is not always emitted. So if my client sends 5 data packets after each other, the readyRead() signal is only emitted between 1 and 3 times (can vary, probably depending on the execution of the client).

    Is this a bug or can I set something in QTcpServer/QTcpSocket to eliminate this problem?

    I think that if the data comes in too quickley, the buffer in QTcpSocket is overridden by the new data. Is this assumption correct? From a networking prespective, what would one do about this? I thought of returing a notification on each data packet. Hence the client will send and then wait for a confirmation from the server until a new packet is send. However, this will drastically reduce the speed of communication (since we always have to send confirmations back to the client). Any better solution?



  • what is the issue you are facing ? Are you not getting all the data ?

    bq. I think that if the data comes in too quickley, the buffer in QTcpSocket is overridden by the new data.

    TCP buffer will not be overwritten. Client needs to read the data. If client is slow, TCP itself get's in and request the server not send data(TCP window size zero)

    bq. I thought of returing a notification on each data packet. Hence the client will send and then wait for a confirmation from the server until a new packet is send. However, this will drastically reduce the speed of communication (since we always have to send confirmations back to the client). Any better solution?

    Since it is TCP connection, TCP protocol layer is already doing what you are thinking.

    It all goes back to the issue you are facing.



  • Never mind. Seems that there was a problem with my WinSock client, which caused the buffer to be overridden, and then the overriden buffer was send to my Qt buffer. So not a Qt problem. Solved!


Log in to reply
 

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