
Originally Posted by
The Storm
Thanks, after some tests it seems that you are right.
Yeah, I know that - I have used canReadLine() with QTcpSocket more than once 
One more question is readLine() called from the TcpSocket appends a terminating C character at the end of the string - '\0' ?
readLine returns a QByteArray, which I think is internally null terminated. But in general the last readable character in the string will be the newline character. You usually use it like so:
while(sock->canReadLine()){
dat = dat.trimmed(); // removes leading and trailing whitespaces
doSomethingWith(dat);
}
while(sock->canReadLine()){
QString dat = sock->readLine();
dat = dat.trimmed(); // removes leading and trailing whitespaces
doSomethingWith(dat);
}
To copy to clipboard, switch view to plain text mode
Remember that QString uses 16b unicode so it is in general not null terminated (or to be precise a null character can exist inside the string).
Bookmarks