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. QTcpSocket write behavior when large num of bytes are written
Forum Updated to NodeBB v4.3 + New Features

QTcpSocket write behavior when large num of bytes are written

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 5 Posters 989 Views 1 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.
  • T Offline
    T Offline
    Taytoo
    wrote on last edited by
    #1

    Standard linux/windows sockets in non-blocking mode return EWOULDBLOCK when a large buffer is written and then we have to wait for the socket to be writable again via epoll/select. Whats the correct procedure to do the same with QTcpSocket? I only see readyRead event in documentation.

    jsulmJ aha_1980A 2 Replies Last reply
    0
    • T Taytoo

      Standard linux/windows sockets in non-blocking mode return EWOULDBLOCK when a large buffer is written and then we have to wait for the socket to be writable again via epoll/select. Whats the correct procedure to do the same with QTcpSocket? I only see readyRead event in documentation.

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

      @Taytoo QTcpSocket has an internal write buffer and takes care of the OS limitations; just make sure not to overrun the internal buffer (which is 2GB AFAIK).

      Regards

      Qt has to stay free or it will die.

      T 1 Reply Last reply
      3
      • T Taytoo

        Standard linux/windows sockets in non-blocking mode return EWOULDBLOCK when a large buffer is written and then we have to wait for the socket to be writable again via epoll/select. Whats the correct procedure to do the same with QTcpSocket? I only see readyRead event in documentation.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @Taytoo You can use https://doc.qt.io/qt-5/qiodevice.html#bytesWritten signal to see how many bytes where written.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2
        • T Taytoo

          Standard linux/windows sockets in non-blocking mode return EWOULDBLOCK when a large buffer is written and then we have to wait for the socket to be writable again via epoll/select. Whats the correct procedure to do the same with QTcpSocket? I only see readyRead event in documentation.

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

          @Taytoo QTcpSocket has an internal write buffer and takes care of the OS limitations; just make sure not to overrun the internal buffer (which is 2GB AFAIK).

          Regards

          Qt has to stay free or it will die.

          T 1 Reply Last reply
          3
          • aha_1980A aha_1980

            @Taytoo QTcpSocket has an internal write buffer and takes care of the OS limitations; just make sure not to overrun the internal buffer (which is 2GB AFAIK).

            Regards

            T Offline
            T Offline
            Taytoo
            wrote on last edited by
            #4

            @aha_1980 said in QTcpSocket write behavior when large num of bytes are written:

            @Taytoo QTcpSocket has an internal write buffer and takes care of the OS limitations; just make sure not to overrun the internal buffer (which is 2GB AFAIK).

            It's an interesting design, while it makes it easy to use qtcpsocket, the problem is that the program won't have any idea how performant the underlying connection is unless we monitor the bytesWritten event and keep track of how much data is pending at any given time.

            JonBJ Pablo J. RoginaP 2 Replies Last reply
            0
            • T Taytoo

              @aha_1980 said in QTcpSocket write behavior when large num of bytes are written:

              @Taytoo QTcpSocket has an internal write buffer and takes care of the OS limitations; just make sure not to overrun the internal buffer (which is 2GB AFAIK).

              It's an interesting design, while it makes it easy to use qtcpsocket, the problem is that the program won't have any idea how performant the underlying connection is unless we monitor the bytesWritten event and keep track of how much data is pending at any given time.

              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by JonB
              #5

              @Taytoo said in QTcpSocket write behavior when large num of bytes are written:

              the program won't have any idea how performant the underlying connection is unless we monitor the bytesWritten event and keep track of how much data is pending at any given time

              If that's what you want your program to do, then write it!

              If you want to monitor at low-level outside, use a tool like wireshark.

              1 Reply Last reply
              1
              • T Taytoo

                @aha_1980 said in QTcpSocket write behavior when large num of bytes are written:

                @Taytoo QTcpSocket has an internal write buffer and takes care of the OS limitations; just make sure not to overrun the internal buffer (which is 2GB AFAIK).

                It's an interesting design, while it makes it easy to use qtcpsocket, the problem is that the program won't have any idea how performant the underlying connection is unless we monitor the bytesWritten event and keep track of how much data is pending at any given time.

                Pablo J. RoginaP Offline
                Pablo J. RoginaP Offline
                Pablo J. Rogina
                wrote on last edited by
                #6

                @Taytoo said in QTcpSocket write behavior when large num of bytes are written:

                the program won't have any idea how performant the underlying connection is unless we monitor the bytesWritten event and keep track of how much data is pending at any given time

                Think about the multi-platform capability of Qt framework, so for lots of developers such OS details independence is a blessing...

                As mentioned in other replies, if you require a super-duper specific kinda low level functionality for a particular OS, you may want to do your own approach. Keep in mind that you can still "mix and match" Qt and some other support libraries. I mean, you can still have all the benefits of Qt GUI for instance, and have your own network module working together.

                Upvote the answer(s) that helped you solve the issue
                Use "Topic Tools" button to mark your post as Solved
                Add screenshots via postimage.org
                Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                1 Reply Last reply
                3

                • Login

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