Qt World Summit: Register Today!

[SOLVED]setting QTcpSocket TCP_NODELAY option

  • Hello.

    In order to assure understanding and correctness:

    I need to set TCP_NODELAY option to QTcpSocket, I found in documentation next function of QAbstractSocket class can be used for that:
    void setSocketOption ( QAbstractSocket::SocketOption option, const QVariant & value )@

    enum QAbstractSocket::SocketOption

    QAbstractSocket::LowDelayOption = 0

    should be used.

    I can't find in the documentation description of value - second function parameter meaning ?
    I do not understand what to put to second parameter value ?
    How can I set that option , whether by next call:

    Thanks in advance.

  • The docs say you should pass the integer "1". Why don't you do that?

  • sorry whether setSocketOption(0); should be called ?
    ( I've edited the previous post ).

    bq. The docs say you should pass the integer “1”. Why don’t you do that?

    Why 1 ? Where is it in docs ?

    do you mean next call :

    ....setSocketOption(QAbstractSocket::LowDelayOption,1); ?


  • [quote]Try to optimize the socket for low latency. For a QTcpSocket this would set the TCP_NODELAY option and disable Nagle's algorithm. Set this to 1 to enable.[/quote]


  • Thanks. Solved.

Log in to reply