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. QAbstractSocket::setSocketOption not working for QAbstractSocket::SendBufferSizeSocketOption
Forum Updated to NodeBB v4.3 + New Features

QAbstractSocket::setSocketOption not working for QAbstractSocket::SendBufferSizeSocketOption

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 2.0k 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.
  • A Offline
    A Offline
    Athil
    wrote on last edited by Athil
    #1

    I tried to use QAbstractSocket::setSocketOption for setting the send buffer size in the following manner:

    code snippet:
    int sizebeforeincreasing = pTcpsocket->socketOption(QAbstractSocket::SendBufferSizeSocketOption).toInt();
    std::cout << "size before:" sizebeforeincreasing << "\n";
    pTcpsocket->setSocketOption(QAbstractSocket::SendBufferSizeSocketOption, 2 * 1024 * 1024);
    int sizeafterincreasing = pTcpsocket->socketOption(QAbstractSocket::SendBufferSizeSocketOption).toInt();

    std:: cout << "size after:" sizeafterincreasing << "\n";

    output:
    size before : 65536
    size after : 65536

    JonBJ 1 Reply Last reply
    0
    • A Athil

      I tried to use QAbstractSocket::setSocketOption for setting the send buffer size in the following manner:

      code snippet:
      int sizebeforeincreasing = pTcpsocket->socketOption(QAbstractSocket::SendBufferSizeSocketOption).toInt();
      std::cout << "size before:" sizebeforeincreasing << "\n";
      pTcpsocket->setSocketOption(QAbstractSocket::SendBufferSizeSocketOption, 2 * 1024 * 1024);
      int sizeafterincreasing = pTcpsocket->socketOption(QAbstractSocket::SendBufferSizeSocketOption).toInt();

      std:: cout << "size after:" sizeafterincreasing << "\n";

      output:
      size before : 65536
      size after : 65536

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Athil
      https://stackoverflow.com/questions/53933227/increase-receive-buffer-size-for-qtcpsocket reports similar behaviour for QAbstractSocket::ReceiveBufferSizeSocketOption on QTcpSocket. Maybe same for SendBufferSizeSocketOption?? If you have to, you might try the appropriate call on the low-level socket descriptor and see whether that does work?

      A 1 Reply Last reply
      0
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        SO_SNDBUF is limited by the OS. For Linux see e.g. here: http://man7.org/linux/man-pages/man7/socket.7.html

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        3
        • JonBJ JonB

          @Athil
          https://stackoverflow.com/questions/53933227/increase-receive-buffer-size-for-qtcpsocket reports similar behaviour for QAbstractSocket::ReceiveBufferSizeSocketOption on QTcpSocket. Maybe same for SendBufferSizeSocketOption?? If you have to, you might try the appropriate call on the low-level socket descriptor and see whether that does work?

          A Offline
          A Offline
          Athil
          wrote on last edited by
          #4

          @JonB said in QAbstractSocket::setSocketOption not working for QAbstractSocket::SendBufferSizeSocketOption:

          https://stackoverflow.com/questions/53933227/increase-receive-buffer-size-for-qtcpsocket

          I tried for ReceiveBufferSizeSocketOption, it is working. Only SendBufferSizeSocketOption is not working.

          JonBJ 1 Reply Last reply
          0
          • A Athil

            @JonB said in QAbstractSocket::setSocketOption not working for QAbstractSocket::SendBufferSizeSocketOption:

            https://stackoverflow.com/questions/53933227/increase-receive-buffer-size-for-qtcpsocket

            I tried for ReceiveBufferSizeSocketOption, it is working. Only SendBufferSizeSocketOption is not working.

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

            @Athil
            Did you read the link posted above by @Christian-Ehrlicher? Are you sure your attempt to increase the send buffer size is not exceeding any specified OS maximum?

            Otherwise, if it were me I'd write a 10 line C program to check what happens if you call the OS level function with SO_SNDBUF; if that does nothing it's not a Qt issue.

            A 1 Reply Last reply
            3
            • JonBJ JonB

              @Athil
              Did you read the link posted above by @Christian-Ehrlicher? Are you sure your attempt to increase the send buffer size is not exceeding any specified OS maximum?

              Otherwise, if it were me I'd write a 10 line C program to check what happens if you call the OS level function with SO_SNDBUF; if that does nothing it's not a Qt issue.

              A Offline
              A Offline
              Athil
              wrote on last edited by
              #6

              @JonB I wrote a sample code using SO_SNDBUF, i was able change the send buffer size using the native api "setsockopt"

              JonBJ 1 Reply Last reply
              0
              • A Athil

                @JonB I wrote a sample code using SO_SNDBUF, i was able change the send buffer size using the native api "setsockopt"

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #7

                @Athil
                Then since you're not getting the answer you want here can only suggest: if you compile Qt yourself then step through debugger, or browse source code, to see what it's actually doing?

                A 1 Reply Last reply
                1
                • JonBJ JonB

                  @Athil
                  Then since you're not getting the answer you want here can only suggest: if you compile Qt yourself then step through debugger, or browse source code, to see what it's actually doing?

                  A Offline
                  A Offline
                  Athil
                  wrote on last edited by
                  #8

                  @JonB Found out the reason
                  case QNativeSocketEngine::SendBufferSocketOption:
                  // see QTBUG-30478 SO_SNDBUF should not be used on Vista or later
                  return false;

                  This is from qt source code

                  JonBJ 1 Reply Last reply
                  2
                  • A Athil

                    @JonB Found out the reason
                    case QNativeSocketEngine::SendBufferSocketOption:
                    // see QTBUG-30478 SO_SNDBUF should not be used on Vista or later
                    return false;

                    This is from qt source code

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #9

                    @Athil
                    There you are! So worth looking at source :)

                    But that shows return false;, I thought you said you had checked the function return result and it was returning true?

                    1 Reply Last reply
                    2

                    • Login

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