Re: QTcpSocket speed problem
What happens to the buffer if you simply discard the data after reading it?
Re: QTcpSocket speed problem
Good question. I'll try it as soon as I get back to my workplace... I cannot access the server from here unfortunately.
After some more googling, I found some posts where people say that while handling readyRead(), after calling bytesAvailable(), it would be wise to read ALL the available data on the socket in one time. Does someone agree with that? Anyway, it sounds awkward to me: it would be like not having a tcp buffer at all.
Again, I'll try it in the next days. Ciao
Re: QTcpSocket speed problem
Yes I agree, at least in theory. The socket buffer most likely is much smaller than 5000*256 bytes.
You could read it all( or less ) in a buffer and then parse it.
regards
Re: QTcpSocket speed problem
Oasn, very often performance problems in QTcpSocket are caused by one of the following
- Not reading (QTcpSocket will reallocate to grow its internal buffer)
- Reading with the QByteArray functions (a new bytearray is allocated for each packet)
- Running network code in the same thread as intensive GUI code (a progress bar will prevent the socket from being read from while continuously drawing itself, which again causes the socket buffer to fill up and start rejecting packets)