[Qt-interest] Why Bus error clientSocket->waitForConnected()?

Arnold Krille arnold at arnoldarts.de
Sun May 2 18:43:00 CEST 2010


On Sunday 02 May 2010 17:56:35 Kustaa Nyholm wrote:
> >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?

The "problem" is that readLine() and canReadLine() are functions of QIODevice. 
And that doesn't know whether the device is a file or a socket or some other 
custom implementation. Blocking at the end of a file to wait till the year 2200 
whether a line might eventually be available doesn't make any sense. So it 
relies on canReadLine() which in turn relies on atEnd() and (probably) peek(). 
And when there is no data currently in the receiving buffer, the sockets 
rightly so return atEnd()==true.

Have fun,

Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100502/4ce02c92/attachment.bin 


More information about the Qt-interest-old mailing list