Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add SO_SNDBUF and SO_RCVBUF to socket options
Added functionality to set SO_SNDBUF and SO_RCVBUF
socket options on QAbstractSocket.

Task-number: QTBUG-34934
Change-Id: I2134fb462d43b9111c039cd7e7d36bd78eafd8bc
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Richard J. Moore <rich@kde.org>
  • Loading branch information
KurtPattyn authored and The Qt Project committed Dec 30, 2013
1 parent d351f3a commit 6aa2273
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
33 changes: 31 additions & 2 deletions src/network/socket/qabstractsocket.cpp
Expand Up @@ -372,9 +372,22 @@
IP_MULTICAST_LOOP (multicast loopback) socket option.
\value TypeOfServiceOption This option is not supported on
Windows. This maps to the IP_TOS socket option.
Windows. This maps to the IP_TOS socket option. For possible values,
see table below.
Possible values for the \e{TypeOfServiceOption} are:
\value SendBufferSizeSocketOption Sets the socket send buffer size
in bytes at the OS level. This maps to the SO_SNDBUF socket option.
This option does not affect the QIODevice or QAbstractSocket buffers.
This enum value has been introduced in Qt 5.3.
\value ReceiveBufferSizeSocketOption Sets the socket receive
buffer size in bytes at the OS level.
This maps to the SO_RCVBUF socket option.
This option does not affect the QIODevice or QAbstractSocket buffers
(see \l{QAbstractSocket::}{setReadBufferSize()}).
This enum value has been introduced in Qt 5.3.
Possible values for \e{TypeOfServiceOption} are:
\table
\header \li Value \li Description
Expand Down Expand Up @@ -1902,6 +1915,14 @@ void QAbstractSocket::setSocketOption(QAbstractSocket::SocketOption option, cons
case TypeOfServiceOption:
d_func()->socketEngine->setOption(QAbstractSocketEngine::TypeOfServiceOption, value.toInt());
break;

case SendBufferSizeSocketOption:
d_func()->socketEngine->setOption(QAbstractSocketEngine::SendBufferSocketOption, value.toInt());
break;

case ReceiveBufferSizeSocketOption:
d_func()->socketEngine->setOption(QAbstractSocketEngine::ReceiveBufferSocketOption, value.toInt());
break;
}
}

Expand Down Expand Up @@ -1936,6 +1957,14 @@ QVariant QAbstractSocket::socketOption(QAbstractSocket::SocketOption option)
case TypeOfServiceOption:
ret = d_func()->socketEngine->option(QAbstractSocketEngine::TypeOfServiceOption);
break;

case SendBufferSizeSocketOption:
ret = d_func()->socketEngine->option(QAbstractSocketEngine::SendBufferSocketOption);
break;

case ReceiveBufferSizeSocketOption:
ret = d_func()->socketEngine->option(QAbstractSocketEngine::ReceiveBufferSocketOption);
break;
}
if (ret == -1)
return QVariant();
Expand Down
4 changes: 3 additions & 1 deletion src/network/socket/qabstractsocket.h
Expand Up @@ -115,7 +115,9 @@ class Q_NETWORK_EXPORT QAbstractSocket : public QIODevice
KeepAliveOption, // SO_KEEPALIVE
MulticastTtlOption, // IP_MULTICAST_TTL
MulticastLoopbackOption, // IP_MULTICAST_LOOPBACK
TypeOfServiceOption //IP_TOS
TypeOfServiceOption, //IP_TOS
SendBufferSizeSocketOption, //SO_SNDBUF
ReceiveBufferSizeSocketOption //SO_RCVBUF
};
enum BindFlag {
DefaultForPlatform = 0x0,
Expand Down

0 comments on commit 6aa2273

Please sign in to comment.