PDA

View Full Version : How to read and write line by line?



Alex Snet
17th April 2009, 14:30
Hi!

How I can read and write information to/from socket line by line?

Now I'm doing this:


tcpSocket.waitForReadyRead();
QByteArray request( tcpSocket.readAll() );


But this is incorrect, because program don't wait two "\r\n" and after first write goes next.

PS I'm writing a small HTTP server.

And also one question: how I can get speed of file downloading? And how I can set it? Or how I can abor connection from UI?

jpn
17th April 2009, 14:45
See QIODevice::readLine().

jpn
17th April 2009, 14:46
For downloading speed, see Implementing TCP Traffic Control (http://doc.trolltech.com/qq/qq17-ratecontrol.html).

AlekseyK
28th November 2010, 15:49
This example does not work since Qt 4.2: http://www.qtcentre.org/threads/10208-How-to-limit-download-speed-with-QHttp?p=167314#post167314

Have You tried it at least once? Does it work for You???