Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Trouble with QIODevice/QAbstractSocket
Forum Updated to NodeBB v4.3 + New Features

Trouble with QIODevice/QAbstractSocket

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 163 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alain38 0
    wrote on last edited by
    #1

    Hi,
    I have to manage a TCP communication between two hosts (P2P connection). But I have some misunderstandings with the API of QIODevice and QAbstractSocket to wait, and be sure that the whole data have been transferred. My problem comes from the fact that QIODevice::write(const QByteArray&) "returns the number of bytes actually written". But in the same time, we have the function QAbstractDevice::waitForBytesWritten() and QIODevice::bytesToWrite().

    So, my questions are:

    • When I send a small amount of data should I call waitForBytesWritten? Or should I only check the return value of write()?

    • When I send a large amount of data should I iterate on waitForByteWritten until bytesToWrite() return 0? And them do not take care of the return value of write().

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      From the looks of it, I would say that the transaction is what you are looking for.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved