diff options
author | Samuel Gaist <samuel.gaist@edeltech.ch> | 2016-09-26 23:38:37 +0200 |
---|---|---|
committer | Samuel Gaist <samuel.gaist@edeltech.ch> | 2016-11-29 14:01:47 +0000 |
commit | 58e1465cb0042899063124ded827f52dd92b8b42 (patch) | |
tree | 80ffb624019628b9d3108d6f2edbbd9473d191f6 /src/network/bearer/qnetworkconfiguration.cpp | |
parent | a0551ae6100a12a0590ef7352b5ea027a442c0d7 (diff) |
Add configurable connect timeout for QAbstractSocket
The aim of this patch is to allow the configuration of the connect
timeout used by QAbstractSocket that is currently hardcoded to 30
seconds.
Using QNetworkConfiguration for this allows to adapt the timeout per
network configuration (e.g. 2G vs wired lan)
[ChangeLog][QtNetwork] The connect timeout from QAbstractSocket
is now configurable through QNetworkConfiguration.
Change-Id: I1dc4051be2c74f925f7a9e0a9ccef332efc2e370
Reviewed-by: Lorn Potter <lorn.potter@canonical.com>
Diffstat (limited to 'src/network/bearer/qnetworkconfiguration.cpp')
-rw-r--r-- | src/network/bearer/qnetworkconfiguration.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/network/bearer/qnetworkconfiguration.cpp b/src/network/bearer/qnetworkconfiguration.cpp index 533a27357c..d2feffb316 100644 --- a/src/network/bearer/qnetworkconfiguration.cpp +++ b/src/network/bearer/qnetworkconfiguration.cpp @@ -326,6 +326,44 @@ bool QNetworkConfiguration::isValid() const } /*! + \since 5.9 + + Returns the connect timeout of this configuration. + + \sa setConnectTimeout +*/ +int QNetworkConfiguration::connectTimeout() const +{ + if (!d) + return QNetworkConfigurationPrivate::DefaultTimeout; + QMutexLocker locker(&d->mutex); + return d->timeout; +} + +/*! + \since 5.9 + + Sets the connect timeout of this configuration. + This allows control of the timeout used by \c QAbstractSocket + to establish a connection. + + \warning This will have no effect if the bearer plugin doesn't have + the CanStartAndStopInterfaces capability. + + Returns true if succeeded. + + \sa connectTimeout +*/ +bool QNetworkConfiguration::setConnectTimeout(int timeout) +{ + if (!d) + return false; + QMutexLocker locker(&d->mutex); + d->timeout = timeout; + return true; +} + +/*! Returns the current state of the configuration. */ QNetworkConfiguration::StateFlags QNetworkConfiguration::state() const |