[Development] [QIODevice]How to correctly treat/understand of the documentation?
Thiago Macieira
thiago.macieira at intel.com
Mon Apr 21 18:12:54 CEST 2014
Em seg 21 abr 2014, às 16:50:50, Denis Shienkov escreveu:
> Hmmm..
>
> Thiago, what do you mean by "writeable"? It is when device was opened in
> the WriteOnly (ReadWrite) mode, or something else?
When the underlying device can receive more bytes from the userspace.
Sockets and pipes are buffered in the kernel. When you write to them, they
don't get sent immediately (for sockets, specifically, there's Nagle's
algorithm in place). They get buffered and sent later.
That buffer is not unlimited in size. When you write too much, the OS will not
accept more write() calls. That is, write() will return -EWOULDBLOCK. When
that happens, you need the QSocketNotifier for Write to tell you when it's
acceptable to write again.
QAbstractSocket and QProcess always put the data in their own buffer during
writeData(). Then they enable the QSocketNotifier for Write, if it wasn't
enabled.
When that notifier fires, in the event loop, the actual writing to the OS
happens.
> If I correctly understand, then I assume that the device always is
> "writeable": i.e. opened in WriteOnly (ReadWrite) and the internal buffer
> of writing is not empty.
You assume wrong. Therefore, the rest of the email does not make sense.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Development
mailing list