[Interest] QFile::write(const QByteArray&) does not write, all data?

Thiago Macieira thiago.macieira at intel.com
Sat May 12 19:48:43 CEST 2018


On Saturday, 12 May 2018 10:08:47 PDT Thiago Macieira wrote:
> No, partial writes are success, so long as they report how much was
> successful. This is the case as well for write(2) and WriteFile.

Note also how this applies to sockets, which use write(): partial writes are a 
success, so the socket code can know how much to drain from the buffer. The 
next write will likely fail with EWOULDBLOCK, but may not depending on 
scheduling.

However, QAbstractSocket is fully buffered and always reports success for its 
writeData(). It will handle the OS partial writes on its own. QFile isn't and 
reports the error back up.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center






More information about the Interest mailing list