[Qt-interest] Why Bus error clientSocket->waitForConnected()?
Kustaa Nyholm
Kustaa.Nyholm at planmeca.com
Sun May 2 17:56:35 CEST 2010
>That's why canReadLine() exists. You shouldn't call readLine() unless you can
>read a line.
I know, I know, my point was that this is not a good API design, two calls
when one would do. And different from say C standard getline() or Java readline,
thus likely to trap many people.
>It does read a line.
Only if a line is available when I make the call.
>What it doesn't do is *block* until more bytes are
>available. Only functions called "waitFor" block.
My point was that it was bad design decision to make this non blocking,
or a bad decision to call it readline when many other APIs/libraries and
common user expectation is that readline will block.
Further, why would anyone want to have it that way?
What purpose does it server?
And the API is even worse in the details, the obvious solution to block until
line is available or the connection is closed:
while( !socket->canReadLine() ) ;
line=socket->readLine();
Is wrong, as the API documentation points out:
"Note that if the peer closes the connection unexpectedly, this function returns FALSE. This means that loops such as this won't work:"
So I think Qt has got this small detail wrong.
br Kusti
More information about the Qt-interest-old
mailing list