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. Why QTcpSocket::waitForBytesWritten returns immediately
Forum Updated to NodeBB v4.3 + New Features

Why QTcpSocket::waitForBytesWritten returns immediately

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.4k Views
  • 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.
  • S Offline
    S Offline
    skibon02
    wrote on last edited by
    #1

    When i send data with QTcpSocket::write, and after use waitForBytesWritten, it returns 1 immediately.
    So when i send big arrays (>5 Mb) wireshark shows, that data still sending, but waitForBytesWritten returns when data not sent yet. QTcpSocket::bytesToWrite also return 0 bytes after calling write function. How can i know when data sent fully?

    P.S. Sorry for my english)

    aha_1980A 1 Reply Last reply
    0
    • S skibon02

      When i send data with QTcpSocket::write, and after use waitForBytesWritten, it returns 1 immediately.
      So when i send big arrays (>5 Mb) wireshark shows, that data still sending, but waitForBytesWritten returns when data not sent yet. QTcpSocket::bytesToWrite also return 0 bytes after calling write function. How can i know when data sent fully?

      P.S. Sorry for my english)

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi @skibon02 ,

      When i send data with QTcpSocket::write, and after use waitForBytesWritten, it returns 1 immediately.
      So when i send big arrays (>5 Mb) wireshark shows, that data still sending, but waitForBytesWritten returns when data not sent yet.
      QTcpSocket::bytesToWrite also return 0 bytes after calling write function.

      That is correct, because QTcpSocket has handed the data to the operating system and from now on it's out of your control. You normally don't know now what is happenening, only be using tools like Wireshark that integrate deeply in OS functions you can visualize what happens.

      How can i know when data sent fully?

      IMHO you cannot.

      Please note that in a distributed network it does not mean much when a TCP packet is sent out, it can have a long way until it's destination. It can even be re-send if the sender does not get an ACK from the receiver.

      What you can do, is to give an acknowlegde from the receiver side once it received the data and evaluate that on the sender side.

      Qt has to stay free or it will die.

      1 Reply Last reply
      3
      • S Offline
        S Offline
        skibon02
        wrote on last edited by
        #3

        Thanks a lot)

        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