QAbstractSocket::setSocketOption not working for QAbstractSocket::SendBufferSizeSocketOption
-
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 -
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@Athil
https://stackoverflow.com/questions/53933227/increase-receive-buffer-size-for-qtcpsocket reports similar behaviour forQAbstractSocket::ReceiveBufferSizeSocketOption
onQTcpSocket
. Maybe same forSendBufferSizeSocketOption
?? If you have to, you might try the appropriate call on the low-level socket descriptor and see whether that does work? -
SO_SNDBUF is limited by the OS. For Linux see e.g. here: http://man7.org/linux/man-pages/man7/socket.7.html
-
@Athil
https://stackoverflow.com/questions/53933227/increase-receive-buffer-size-for-qtcpsocket reports similar behaviour forQAbstractSocket::ReceiveBufferSizeSocketOption
onQTcpSocket
. Maybe same forSendBufferSizeSocketOption
?? If you have to, you might try the appropriate call on the low-level socket descriptor and see whether that does work?@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.
-
@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.
@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. -
@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. -
@JonB I wrote a sample code using SO_SNDBUF, i was able change the send buffer size using the native api "setsockopt"
-
@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? -
@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