| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtNetwork module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | //#define QNATIVESOCKETENGINE_DEBUG | - |
| 43 | | - |
| 44 | /*! \class QNativeSocketEngine | - |
| 45 | \internal | - |
| 46 | | - |
| 47 | \brief The QNativeSocketEngine class provides low level access to a socket. | - |
| 48 | | - |
| 49 | \reentrant | - |
| 50 | \ingroup network | - |
| 51 | \inmodule QtNetwork | - |
| 52 | | - |
| 53 | QtSocketLayer provides basic socket functionality provided by the | - |
| 54 | operating system. It also keeps track of what state the socket is | - |
| 55 | in, and which errors that occur. | - |
| 56 | | - |
| 57 | The classes QTcpSocket, QUdpSocket and QTcpServer provide a | - |
| 58 | higher level API, and are in general more useful for the common | - |
| 59 | application. | - |
| 60 | | - |
| 61 | There are two main ways of initializing the a QNativeSocketEngine; either | - |
| 62 | create a new socket by passing the socket type (TcpSocket or | - |
| 63 | UdpSocket) and network layer protocol (IPv4Protocol or | - |
| 64 | IPv6Protocol) to initialize(), or pass an existing socket | - |
| 65 | descriptor and have QNativeSocketEngine determine the type and protocol | - |
| 66 | itself. The native socket descriptor can later be fetched by | - |
| 67 | calling socketDescriptor(). The socket is made non-blocking, but | - |
| 68 | blocking behavior can still be achieved by calling waitForRead() | - |
| 69 | and waitForWrite(). isValid() can be called to check if the socket | - |
| 70 | has been successfully initialized and is ready to use. | - |
| 71 | | - |
| 72 | To connect to a host, determine its address and pass this and the | - |
| 73 | port number to connectToHost(). The socket can then be used as a | - |
| 74 | TCP or UDP client. Otherwise; bind(), listen() and accept() are | - |
| 75 | used to have the socket function as a TCP or UDP server. Call | - |
| 76 | close() to close the socket. | - |
| 77 | | - |
| 78 | bytesAvailable() is called to determine how much data is available | - |
| 79 | for reading. read() and write() are used by both TCP and UDP | - |
| 80 | clients to exchange data with the connected peer. UDP clients can | - |
| 81 | also call hasMoreDatagrams(), nextDatagramSize(), | - |
| 82 | readDatagram(), and writeDatagram(). | - |
| 83 | | - |
| 84 | Call state() to determine the state of the socket, for | - |
| 85 | example, ListeningState or ConnectedState. socketType() tells | - |
| 86 | whether the socket is a TCP socket or a UDP socket, or if the | - |
| 87 | socket type is unknown. protocol() is used to determine the | - |
| 88 | socket's network layer protocol. | - |
| 89 | | - |
| 90 | localAddress(), localPort() are called to find the address and | - |
| 91 | port that are currently bound to the socket. If the socket is | - |
| 92 | connected, peerAddress() and peerPort() determine the address and | - |
| 93 | port of the connected peer. | - |
| 94 | | - |
| 95 | Finally, if any function should fail, error() and | - |
| 96 | errorString() can be called to determine the cause of the error. | - |
| 97 | */ | - |
| 98 | | - |
| 99 | #include "qnativesocketengine_p.h" | - |
| 100 | | - |
| 101 | #include <qabstracteventdispatcher.h> | - |
| 102 | #include <qsocketnotifier.h> | - |
| 103 | #include <qnetworkinterface.h> | - |
| 104 | | - |
| 105 | #include <private/qthread_p.h> | - |
| 106 | #include <private/qobject_p.h> | - |
| 107 | | - |
| 108 | #if !defined(QT_NO_NETWORKPROXY) | - |
| 109 | # include "qnetworkproxy.h" | - |
| 110 | # include "qabstractsocket.h" | - |
| 111 | # include "qtcpserver.h" | - |
| 112 | #endif | - |
| 113 | | - |
| 114 | QT_BEGIN_NAMESPACE | - |
| 115 | | - |
| 116 | //#define QNATIVESOCKETENGINE_DEBUG | - |
| 117 | | - |
| 118 | #define Q_VOID | - |
| 119 | | - |
| 120 | // Common constructs | - |
| 121 | #define Q_CHECK_VALID_SOCKETLAYER(function, returnValue) do { \ | - |
| 122 | if (!isValid()) { \ | - |
| 123 | qWarning(""#function" was called on an uninitialized socket device"); \ | - |
| 124 | return returnValue; \ | - |
| 125 | } } while (0) | - |
| 126 | #define Q_CHECK_INVALID_SOCKETLAYER(function, returnValue) do { \ | - |
| 127 | if (isValid()) { \ | - |
| 128 | qWarning(""#function" was called on an already initialized socket device"); \ | - |
| 129 | return returnValue; \ | - |
| 130 | } } while (0) | - |
| 131 | #define Q_CHECK_STATE(function, checkState, returnValue) do { \ | - |
| 132 | if (d->socketState != (checkState)) { \ | - |
| 133 | qWarning(""#function" was not called in "#checkState); \ | - |
| 134 | return (returnValue); \ | - |
| 135 | } } while (0) | - |
| 136 | #define Q_CHECK_NOT_STATE(function, checkState, returnValue) do { \ | - |
| 137 | if (d->socketState == (checkState)) { \ | - |
| 138 | qWarning(""#function" was called in "#checkState); \ | - |
| 139 | return (returnValue); \ | - |
| 140 | } } while (0) | - |
| 141 | #define Q_CHECK_STATES(function, state1, state2, returnValue) do { \ | - |
| 142 | if (d->socketState != (state1) && d->socketState != (state2)) { \ | - |
| 143 | qWarning(""#function" was called" \ | - |
| 144 | " not in "#state1" or "#state2); \ | - |
| 145 | return (returnValue); \ | - |
| 146 | } } while (0) | - |
| 147 | #define Q_CHECK_TYPE(function, type, returnValue) do { \ | - |
| 148 | if (d->socketType != (type)) { \ | - |
| 149 | qWarning(#function" was called by a" \ | - |
| 150 | " socket other than "#type""); \ | - |
| 151 | return (returnValue); \ | - |
| 152 | } } while (0) | - |
| 153 | #define Q_TR(a) QT_TRANSLATE_NOOP(QNativeSocketEngine, a) | - |
| 154 | | - |
| 155 | /*! \internal | - |
| 156 | Constructs the private class and initializes all data members. | - |
| 157 | | - |
| 158 | On Windows, WSAStartup is called "recursively" for every | - |
| 159 | concurrent QNativeSocketEngine. This is safe, because WSAStartup and | - |
| 160 | WSACleanup are reference counted. | - |
| 161 | */ | - |
| 162 | QNativeSocketEnginePrivate::QNativeSocketEnginePrivate() : | - |
| 163 | socketDescriptor(-1), | - |
| 164 | readNotifier(0), | - |
| 165 | writeNotifier(0), | - |
| 166 | exceptNotifier(0) | - |
| 167 | { | - |
| 168 | } executed: }Execution Count:3376 | 3376 |
| 169 | | - |
| 170 | /*! \internal | - |
| 171 | Destructs the private class. | - |
| 172 | */ | - |
| 173 | QNativeSocketEnginePrivate::~QNativeSocketEnginePrivate() | - |
| 174 | { | - |
| 175 | } | - |
| 176 | | - |
| 177 | /*! \internal | - |
| 178 | | - |
| 179 | Sets the error and error string if not set already. The only | - |
| 180 | interesting error is the first one that occurred, and not the last | - |
| 181 | one. | - |
| 182 | */ | - |
| 183 | void QNativeSocketEnginePrivate::setError(QAbstractSocket::SocketError error, ErrorString errorString) const | - |
| 184 | { | - |
| 185 | if (hasSetSocketError) { evaluated: hasSetSocketError| yes Evaluation Count:64 | yes Evaluation Count:2903 |
| 64-2903 |
| 186 | // Only set socket errors once for one engine; expect the | - |
| 187 | // socket to recreate its engine after an error. Note: There's | - |
| 188 | // one exception: SocketError(11) bypasses this as it's purely | - |
| 189 | // a temporary internal error condition. | - |
| 190 | // Another exception is the way the waitFor*() functions set | - |
| 191 | // an error when a timeout occurs. After the call to setError() | - |
| 192 | // they reset the hasSetSocketError to false | - |
| 193 | return; executed: return;Execution Count:64 | 64 |
| 194 | } | - |
| 195 | if (error != QAbstractSocket::SocketError(11)) evaluated: error != QAbstractSocket::SocketError(11)| yes Evaluation Count:816 | yes Evaluation Count:2087 |
| 816-2087 |
| 196 | hasSetSocketError = true; executed: hasSetSocketError = true;Execution Count:816 | 816 |
| 197 | | - |
| 198 | socketError = error; executed (the execution status of this line is deduced): socketError = error; | - |
| 199 | | - |
| 200 | switch (errorString) { | - |
| 201 | case NonBlockingInitFailedErrorString: | - |
| 202 | socketErrorString = QNativeSocketEngine::tr("Unable to initialize non-blocking socket"); never executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Unable to initialize non-blocking socket"); | - |
| 203 | break; | 0 |
| 204 | case BroadcastingInitFailedErrorString: | - |
| 205 | socketErrorString = QNativeSocketEngine::tr("Unable to initialize broadcast socket"); never executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Unable to initialize broadcast socket"); | - |
| 206 | break; | 0 |
| 207 | // should not happen anymore | - |
| 208 | case NoIpV6ErrorString: | - |
| 209 | socketErrorString = QNativeSocketEngine::tr("Attempt to use IPv6 socket on a platform with no IPv6 support"); never executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Attempt to use IPv6 socket on a platform with no IPv6 support"); | - |
| 210 | break; | 0 |
| 211 | case RemoteHostClosedErrorString: | - |
| 212 | socketErrorString = QNativeSocketEngine::tr("The remote host closed the connection"); executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("The remote host closed the connection"); | - |
| 213 | break; executed: break;Execution Count:333 | 333 |
| 214 | case TimeOutErrorString: | - |
| 215 | socketErrorString = QNativeSocketEngine::tr("Network operation timed out"); executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Network operation timed out"); | - |
| 216 | break; executed: break;Execution Count:64 | 64 |
| 217 | case ResourceErrorString: | - |
| 218 | socketErrorString = QNativeSocketEngine::tr("Out of resources"); never executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Out of resources"); | - |
| 219 | break; | 0 |
| 220 | case OperationUnsupportedErrorString: | - |
| 221 | socketErrorString = QNativeSocketEngine::tr("Unsupported socket operation"); never executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Unsupported socket operation"); | - |
| 222 | break; | 0 |
| 223 | case ProtocolUnsupportedErrorString: | - |
| 224 | socketErrorString = QNativeSocketEngine::tr("Protocol type not supported"); never executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Protocol type not supported"); | - |
| 225 | break; | 0 |
| 226 | case InvalidSocketErrorString: | - |
| 227 | socketErrorString = QNativeSocketEngine::tr("Invalid socket descriptor"); executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Invalid socket descriptor"); | - |
| 228 | break; executed: break;Execution Count:2089 | 2089 |
| 229 | case HostUnreachableErrorString: | - |
| 230 | socketErrorString = QNativeSocketEngine::tr("Host unreachable"); never executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Host unreachable"); | - |
| 231 | break; | 0 |
| 232 | case NetworkUnreachableErrorString: | - |
| 233 | socketErrorString = QNativeSocketEngine::tr("Network unreachable"); executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Network unreachable"); | - |
| 234 | break; executed: break;Execution Count:2 | 2 |
| 235 | case AccessErrorString: | - |
| 236 | socketErrorString = QNativeSocketEngine::tr("Permission denied"); never executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Permission denied"); | - |
| 237 | break; | 0 |
| 238 | case ConnectionTimeOutErrorString: | - |
| 239 | socketErrorString = QNativeSocketEngine::tr("Connection timed out"); never executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Connection timed out"); | - |
| 240 | break; | 0 |
| 241 | case ConnectionRefusedErrorString: | - |
| 242 | socketErrorString = QNativeSocketEngine::tr("Connection refused"); executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Connection refused"); | - |
| 243 | break; executed: break;Execution Count:8 | 8 |
| 244 | case AddressInuseErrorString: | - |
| 245 | socketErrorString = QNativeSocketEngine::tr("The bound address is already in use"); executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("The bound address is already in use"); | - |
| 246 | break; executed: break;Execution Count:9 | 9 |
| 247 | case AddressNotAvailableErrorString: | - |
| 248 | socketErrorString = QNativeSocketEngine::tr("The address is not available"); executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("The address is not available"); | - |
| 249 | break; executed: break;Execution Count:1 | 1 |
| 250 | case AddressProtectedErrorString: | - |
| 251 | socketErrorString = QNativeSocketEngine::tr("The address is protected"); never executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("The address is protected"); | - |
| 252 | break; | 0 |
| 253 | case DatagramTooLargeErrorString: | - |
| 254 | socketErrorString = QNativeSocketEngine::tr("Datagram was too large to send"); executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Datagram was too large to send"); | - |
| 255 | break; executed: break;Execution Count:1 | 1 |
| 256 | case SendDatagramErrorString: | - |
| 257 | socketErrorString = QNativeSocketEngine::tr("Unable to send a message"); never executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Unable to send a message"); | - |
| 258 | break; | 0 |
| 259 | case ReceiveDatagramErrorString: | - |
| 260 | socketErrorString = QNativeSocketEngine::tr("Unable to receive a message"); never executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Unable to receive a message"); | - |
| 261 | break; | 0 |
| 262 | case WriteErrorString: | - |
| 263 | socketErrorString = QNativeSocketEngine::tr("Unable to write"); never executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Unable to write"); | - |
| 264 | break; | 0 |
| 265 | case ReadErrorString: | - |
| 266 | socketErrorString = QNativeSocketEngine::tr("Network error"); never executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Network error"); | - |
| 267 | break; | 0 |
| 268 | case PortInuseErrorString: | - |
| 269 | socketErrorString = QNativeSocketEngine::tr("Another socket is already listening on the same port"); never executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Another socket is already listening on the same port"); | - |
| 270 | break; | 0 |
| 271 | case NotSocketErrorString: | - |
| 272 | socketErrorString = QNativeSocketEngine::tr("Operation on non-socket"); never executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Operation on non-socket"); | - |
| 273 | break; | 0 |
| 274 | case InvalidProxyTypeString: | - |
| 275 | socketErrorString = QNativeSocketEngine::tr("The proxy type is invalid for this operation"); executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("The proxy type is invalid for this operation"); | - |
| 276 | break; executed: break;Execution Count:1 | 1 |
| 277 | case TemporaryErrorString: | - |
| 278 | socketErrorString = QNativeSocketEngine::tr("Temporary error"); executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Temporary error"); | - |
| 279 | break; executed: break;Execution Count:394 | 394 |
| 280 | case UnknownSocketErrorString: | - |
| 281 | socketErrorString = QNativeSocketEngine::tr("Unknown error"); executed (the execution status of this line is deduced): socketErrorString = QNativeSocketEngine::tr("Unknown error"); | - |
| 282 | break; executed: break;Execution Count:1 | 1 |
| 283 | } | - |
| 284 | } executed: }Execution Count:2903 | 2903 |
| 285 | | - |
| 286 | bool QNativeSocketEnginePrivate::checkProxy(const QHostAddress &address) | - |
| 287 | { | - |
| 288 | if (address.isLoopback()) evaluated: address.isLoopback()| yes Evaluation Count:1854 | yes Evaluation Count:2104 |
| 1854-2104 |
| 289 | return true; executed: return true;Execution Count:1854 | 1854 |
| 290 | | - |
| 291 | #if !defined(QT_NO_NETWORKPROXY) | - |
| 292 | QObject *parent = q_func()->parent(); executed (the execution status of this line is deduced): QObject *parent = q_func()->parent(); | - |
| 293 | QNetworkProxy proxy; executed (the execution status of this line is deduced): QNetworkProxy proxy; | - |
| 294 | if (QAbstractSocket *socket = qobject_cast<QAbstractSocket *>(parent)) { evaluated: QAbstractSocket *socket = qobject_cast<QAbstractSocket *>(parent)| yes Evaluation Count:1688 | yes Evaluation Count:416 |
| 416-1688 |
| 295 | proxy = socket->proxy(); executed (the execution status of this line is deduced): proxy = socket->proxy(); | - |
| 296 | } else if (QTcpServer *server = qobject_cast<QTcpServer *>(parent)) { executed: }Execution Count:1688 partially evaluated: QTcpServer *server = qobject_cast<QTcpServer *>(parent)| yes Evaluation Count:416 | no Evaluation Count:0 |
| 0-1688 |
| 297 | proxy = server->proxy(); executed (the execution status of this line is deduced): proxy = server->proxy(); | - |
| 298 | } else { executed: }Execution Count:416 | 416 |
| 299 | // no parent -> no proxy | - |
| 300 | return true; never executed: return true; | 0 |
| 301 | } | - |
| 302 | | - |
| 303 | if (proxy.type() == QNetworkProxy::DefaultProxy) evaluated: proxy.type() == QNetworkProxy::DefaultProxy| yes Evaluation Count:856 | yes Evaluation Count:1248 |
| 856-1248 |
| 304 | proxy = QNetworkProxy::applicationProxy(); executed: proxy = QNetworkProxy::applicationProxy();Execution Count:856 | 856 |
| 305 | | - |
| 306 | if (proxy.type() != QNetworkProxy::DefaultProxy && partially evaluated: proxy.type() != QNetworkProxy::DefaultProxy| yes Evaluation Count:2104 | no Evaluation Count:0 |
| 0-2104 |
| 307 | proxy.type() != QNetworkProxy::NoProxy) { evaluated: proxy.type() != QNetworkProxy::NoProxy| yes Evaluation Count:1 | yes Evaluation Count:2103 |
| 1-2103 |
| 308 | // QNativeSocketEngine doesn't do proxies | - |
| 309 | setError(QAbstractSocket::UnsupportedSocketOperationError, executed (the execution status of this line is deduced): setError(QAbstractSocket::UnsupportedSocketOperationError, | - |
| 310 | QNativeSocketEnginePrivate::InvalidProxyTypeString); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate::InvalidProxyTypeString); | - |
| 311 | return false; executed: return false;Execution Count:1 | 1 |
| 312 | } | - |
| 313 | #endif | - |
| 314 | | - |
| 315 | return true; executed: return true;Execution Count:2103 | 2103 |
| 316 | } | - |
| 317 | | - |
| 318 | /*! | - |
| 319 | Constructs a QNativeSocketEngine. | - |
| 320 | | - |
| 321 | \sa initialize() | - |
| 322 | */ | - |
| 323 | QNativeSocketEngine::QNativeSocketEngine(QObject *parent) | - |
| 324 | : QAbstractSocketEngine(*new QNativeSocketEnginePrivate(), parent) | - |
| 325 | { | - |
| 326 | } executed: }Execution Count:3376 | 3376 |
| 327 | | - |
| 328 | /*! | - |
| 329 | Destructs a QNativeSocketEngine. | - |
| 330 | */ | - |
| 331 | QNativeSocketEngine::~QNativeSocketEngine() | - |
| 332 | { | - |
| 333 | close(); executed (the execution status of this line is deduced): close(); | - |
| 334 | } executed: }Execution Count:3374 | 3374 |
| 335 | | - |
| 336 | /*! | - |
| 337 | Initializes a QNativeSocketEngine by creating a new socket of type \a | - |
| 338 | socketType and network layer protocol \a protocol. Returns true on | - |
| 339 | success; otherwise returns false. | - |
| 340 | | - |
| 341 | If the socket was already initialized, this function closes the | - |
| 342 | socket before reeinitializing it. | - |
| 343 | | - |
| 344 | The new socket is non-blocking, and for UDP sockets it's also | - |
| 345 | broadcast enabled. | - |
| 346 | */ | - |
| 347 | bool QNativeSocketEngine::initialize(QAbstractSocket::SocketType socketType, QAbstractSocket::NetworkLayerProtocol protocol) | - |
| 348 | { | - |
| 349 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 350 | if (isValid()) partially evaluated: isValid()| no Evaluation Count:0 | yes Evaluation Count:2761 |
| 0-2761 |
| 351 | close(); | 0 |
| 352 | | - |
| 353 | // Create the socket | - |
| 354 | if (!d->createNewSocket(socketType, protocol)) { partially evaluated: !d->createNewSocket(socketType, protocol)| no Evaluation Count:0 | yes Evaluation Count:2761 |
| 0-2761 |
| 355 | #if defined (QNATIVESOCKETENGINE_DEBUG) | - |
| 356 | QString typeStr = QLatin1String("UnknownSocketType"); | - |
| 357 | if (socketType == QAbstractSocket::TcpSocket) typeStr = QLatin1String("TcpSocket"); | - |
| 358 | else if (socketType == QAbstractSocket::UdpSocket) typeStr = QLatin1String("UdpSocket"); | - |
| 359 | QString protocolStr = QLatin1String("UnknownProtocol"); | - |
| 360 | if (protocol == QAbstractSocket::IPv4Protocol) protocolStr = QLatin1String("IPv4Protocol"); | - |
| 361 | else if (protocol == QAbstractSocket::IPv6Protocol) protocolStr = QLatin1String("IPv6Protocol"); | - |
| 362 | qDebug("QNativeSocketEngine::initialize(type == %s, protocol == %s) failed: %s", | - |
| 363 | typeStr.toLatin1().constData(), protocolStr.toLatin1().constData(), d->socketErrorString.toLatin1().constData()); | - |
| 364 | #endif | - |
| 365 | return false; never executed: return false; | 0 |
| 366 | } | - |
| 367 | | - |
| 368 | // Make the socket nonblocking. | - |
| 369 | if (!setOption(NonBlockingSocketOption, 1)) { partially evaluated: !setOption(NonBlockingSocketOption, 1)| no Evaluation Count:0 | yes Evaluation Count:2761 |
| 0-2761 |
| 370 | d->setError(QAbstractSocket::UnsupportedSocketOperationError, never executed (the execution status of this line is deduced): d->setError(QAbstractSocket::UnsupportedSocketOperationError, | - |
| 371 | QNativeSocketEnginePrivate::NonBlockingInitFailedErrorString); never executed (the execution status of this line is deduced): QNativeSocketEnginePrivate::NonBlockingInitFailedErrorString); | - |
| 372 | close(); never executed (the execution status of this line is deduced): close(); | - |
| 373 | return false; never executed: return false; | 0 |
| 374 | } | - |
| 375 | | - |
| 376 | // Set the broadcasting flag if it's a UDP socket. | - |
| 377 | if (socketType == QAbstractSocket::UdpSocket evaluated: socketType == QAbstractSocket::UdpSocket| yes Evaluation Count:235 | yes Evaluation Count:2526 |
| 235-2526 |
| 378 | && !setOption(BroadcastSocketOption, 1)) { partially evaluated: !setOption(BroadcastSocketOption, 1)| no Evaluation Count:0 | yes Evaluation Count:235 |
| 0-235 |
| 379 | d->setError(QAbstractSocket::UnsupportedSocketOperationError, never executed (the execution status of this line is deduced): d->setError(QAbstractSocket::UnsupportedSocketOperationError, | - |
| 380 | QNativeSocketEnginePrivate::BroadcastingInitFailedErrorString); never executed (the execution status of this line is deduced): QNativeSocketEnginePrivate::BroadcastingInitFailedErrorString); | - |
| 381 | close(); never executed (the execution status of this line is deduced): close(); | - |
| 382 | return false; never executed: return false; | 0 |
| 383 | } | - |
| 384 | | - |
| 385 | | - |
| 386 | // Make sure we receive out-of-band data | - |
| 387 | if (socketType == QAbstractSocket::TcpSocket evaluated: socketType == QAbstractSocket::TcpSocket| yes Evaluation Count:2526 | yes Evaluation Count:235 |
| 235-2526 |
| 388 | && !setOption(ReceiveOutOfBandData, 1)) { partially evaluated: !setOption(ReceiveOutOfBandData, 1)| no Evaluation Count:0 | yes Evaluation Count:2526 |
| 0-2526 |
| 389 | qWarning("QNativeSocketEngine::initialize unable to inline out-of-band data"); never executed (the execution status of this line is deduced): QMessageLogger("socket/qnativesocketengine.cpp", 389, __PRETTY_FUNCTION__).warning("QNativeSocketEngine::initialize unable to inline out-of-band data"); | - |
| 390 | } | 0 |
| 391 | | - |
| 392 | // Before Qt 4.6, we always set the send and receive buffer size to 49152 as | - |
| 393 | // this was found to be an optimal value. However, modern OS | - |
| 394 | // all have some kind of auto tuning for this and we therefore don't set | - |
| 395 | // this explictly anymore. | - |
| 396 | // If it introduces any performance regressions for Qt 4.6.x (x > 0) then | - |
| 397 | // it will be put back in. | - |
| 398 | // | - |
| 399 | // You can use tests/manual/qhttpnetworkconnection to test HTTP download speed | - |
| 400 | // with this. | - |
| 401 | // | - |
| 402 | // pre-4.6: | - |
| 403 | // setReceiveBufferSize(49152); | - |
| 404 | // setSendBufferSize(49152); | - |
| 405 | | - |
| 406 | d->socketType = socketType; executed (the execution status of this line is deduced): d->socketType = socketType; | - |
| 407 | d->socketProtocol = protocol; executed (the execution status of this line is deduced): d->socketProtocol = protocol; | - |
| 408 | return true; executed: return true;Execution Count:2761 | 2761 |
| 409 | } | - |
| 410 | | - |
| 411 | /*! \overload | - |
| 412 | | - |
| 413 | Initializes the socket using \a socketDescriptor instead of | - |
| 414 | creating a new one. The socket type and network layer protocol are | - |
| 415 | determined automatically. The socket's state is set to \a | - |
| 416 | socketState. | - |
| 417 | | - |
| 418 | If the socket type is either TCP or UDP, it is made non-blocking. | - |
| 419 | UDP sockets are also broadcast enabled. | - |
| 420 | */ | - |
| 421 | bool QNativeSocketEngine::initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState) | - |
| 422 | { | - |
| 423 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 424 | | - |
| 425 | if (isValid()) partially evaluated: isValid()| no Evaluation Count:0 | yes Evaluation Count:615 |
| 0-615 |
| 426 | close(); | 0 |
| 427 | | - |
| 428 | d->socketDescriptor = socketDescriptor; executed (the execution status of this line is deduced): d->socketDescriptor = socketDescriptor; | - |
| 429 | | - |
| 430 | // determine socket type and protocol | - |
| 431 | if (!d->fetchConnectionParameters()) { evaluated: !d->fetchConnectionParameters()| yes Evaluation Count:3 | yes Evaluation Count:612 |
| 3-612 |
| 432 | #if defined (QNATIVESOCKETENGINE_DEBUG) | - |
| 433 | qDebug("QNativeSocketEngine::initialize(socketDescriptor == %i) failed: %s", | - |
| 434 | socketDescriptor, d->socketErrorString.toLatin1().constData()); | - |
| 435 | #endif | - |
| 436 | d->socketDescriptor = -1; executed (the execution status of this line is deduced): d->socketDescriptor = -1; | - |
| 437 | return false; executed: return false;Execution Count:3 | 3 |
| 438 | } | - |
| 439 | | - |
| 440 | if (d->socketType != QAbstractSocket::UnknownSocketType) { partially evaluated: d->socketType != QAbstractSocket::UnknownSocketType| yes Evaluation Count:612 | no Evaluation Count:0 |
| 0-612 |
| 441 | // Make the socket nonblocking. | - |
| 442 | if (!setOption(NonBlockingSocketOption, 1)) { partially evaluated: !setOption(NonBlockingSocketOption, 1)| no Evaluation Count:0 | yes Evaluation Count:612 |
| 0-612 |
| 443 | d->setError(QAbstractSocket::UnsupportedSocketOperationError, never executed (the execution status of this line is deduced): d->setError(QAbstractSocket::UnsupportedSocketOperationError, | - |
| 444 | QNativeSocketEnginePrivate::NonBlockingInitFailedErrorString); never executed (the execution status of this line is deduced): QNativeSocketEnginePrivate::NonBlockingInitFailedErrorString); | - |
| 445 | close(); never executed (the execution status of this line is deduced): close(); | - |
| 446 | return false; never executed: return false; | 0 |
| 447 | } | - |
| 448 | | - |
| 449 | // Set the broadcasting flag if it's a UDP socket. | - |
| 450 | if (d->socketType == QAbstractSocket::UdpSocket partially evaluated: d->socketType == QAbstractSocket::UdpSocket| no Evaluation Count:0 | yes Evaluation Count:612 |
| 0-612 |
| 451 | && !setOption(BroadcastSocketOption, 1)) { never evaluated: !setOption(BroadcastSocketOption, 1) | 0 |
| 452 | d->setError(QAbstractSocket::UnsupportedSocketOperationError, never executed (the execution status of this line is deduced): d->setError(QAbstractSocket::UnsupportedSocketOperationError, | - |
| 453 | QNativeSocketEnginePrivate::BroadcastingInitFailedErrorString); never executed (the execution status of this line is deduced): QNativeSocketEnginePrivate::BroadcastingInitFailedErrorString); | - |
| 454 | close(); never executed (the execution status of this line is deduced): close(); | - |
| 455 | return false; never executed: return false; | 0 |
| 456 | } | - |
| 457 | } executed: }Execution Count:612 | 612 |
| 458 | | - |
| 459 | d->socketState = socketState; executed (the execution status of this line is deduced): d->socketState = socketState; | - |
| 460 | return true; executed: return true;Execution Count:612 | 612 |
| 461 | } | - |
| 462 | | - |
| 463 | /*! | - |
| 464 | Returns true if the socket is valid; otherwise returns false. A | - |
| 465 | socket is valid if it has not been successfully initialized, or if | - |
| 466 | it has been closed. | - |
| 467 | */ | - |
| 468 | bool QNativeSocketEngine::isValid() const | - |
| 469 | { | - |
| 470 | Q_D(const QNativeSocketEngine); executed (the execution status of this line is deduced): const QNativeSocketEnginePrivate * const d = d_func(); | - |
| 471 | return d->socketDescriptor != -1; executed: return d->socketDescriptor != -1;Execution Count:7595494 | 7595494 |
| 472 | } | - |
| 473 | | - |
| 474 | /*! | - |
| 475 | Returns the native socket descriptor. Any use of this descriptor | - |
| 476 | stands the risk of being non-portable. | - |
| 477 | */ | - |
| 478 | qintptr QNativeSocketEngine::socketDescriptor() const | - |
| 479 | { | - |
| 480 | Q_D(const QNativeSocketEngine); executed (the execution status of this line is deduced): const QNativeSocketEnginePrivate * const d = d_func(); | - |
| 481 | return d->socketDescriptor; executed: return d->socketDescriptor;Execution Count:328162 | 328162 |
| 482 | } | - |
| 483 | | - |
| 484 | /*! | - |
| 485 | Connects to the IP address and port specified by \a address and \a | - |
| 486 | port. If the connection is established, this function returns true | - |
| 487 | and the socket enters ConnectedState. Otherwise, false is | - |
| 488 | returned. | - |
| 489 | | - |
| 490 | If false is returned, state() should be called to see if the | - |
| 491 | socket is in ConnectingState. If so, a delayed TCP connection is | - |
| 492 | taking place, and connectToHost() must be called again later to | - |
| 493 | determine if the connection was established successfully or | - |
| 494 | not. The second connection attempt must be made when the socket is | - |
| 495 | ready for writing. This state can be determined either by | - |
| 496 | connecting a QSocketNotifier to the socket descriptor returned by | - |
| 497 | socketDescriptor(), or by calling the blocking function | - |
| 498 | waitForWrite(). | - |
| 499 | | - |
| 500 | Example: | - |
| 501 | \snippet code/src_network_socket_qnativesocketengine.cpp 0 | - |
| 502 | | - |
| 503 | Otherwise, error() should be called to determine the cause of the | - |
| 504 | error. | - |
| 505 | */ | - |
| 506 | bool QNativeSocketEngine::connectToHost(const QHostAddress &address, quint16 port) | - |
| 507 | { | - |
| 508 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 509 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::connectToHost(), false); never executed: return false; executed: }Execution Count:3288 partially evaluated: !isValid()| no Evaluation Count:0 | yes Evaluation Count:3288 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:3288 |
| 0-3288 |
| 510 | | - |
| 511 | if (!d->checkProxy(address)) partially evaluated: !d->checkProxy(address)| no Evaluation Count:0 | yes Evaluation Count:3288 |
| 0-3288 |
| 512 | return false; never executed: return false; | 0 |
| 513 | | - |
| 514 | Q_CHECK_STATES(QNativeSocketEngine::connectToHost(), never executed: return (false); executed: }Execution Count:3288 partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:3288 |
evaluated: d->socketState != (QAbstractSocket::UnconnectedState)| yes Evaluation Count:1195 | yes Evaluation Count:2093 |
partially evaluated: d->socketState != (QAbstractSocket::ConnectingState)| no Evaluation Count:0 | yes Evaluation Count:1195 |
| 0-3288 |
| 515 | QAbstractSocket::UnconnectedState, QAbstractSocket::ConnectingState, false); | - |
| 516 | | - |
| 517 | d->peerAddress = address; executed (the execution status of this line is deduced): d->peerAddress = address; | - |
| 518 | d->peerPort = port; executed (the execution status of this line is deduced): d->peerPort = port; | - |
| 519 | bool connected = d->nativeConnect(address, port); executed (the execution status of this line is deduced): bool connected = d->nativeConnect(address, port); | - |
| 520 | if (connected) evaluated: connected| yes Evaluation Count:1191 | yes Evaluation Count:2097 |
| 1191-2097 |
| 521 | d->fetchConnectionParameters(); executed: d->fetchConnectionParameters();Execution Count:1191 | 1191 |
| 522 | | - |
| 523 | return connected; executed: return connected;Execution Count:3288 | 3288 |
| 524 | } | - |
| 525 | | - |
| 526 | /*! | - |
| 527 | If there's a connection activity on the socket, process it. Then | - |
| 528 | notify our parent if there really was activity. | - |
| 529 | */ | - |
| 530 | void QNativeSocketEngine::connectionNotification() | - |
| 531 | { | - |
| 532 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 533 | Q_ASSERT(state() == QAbstractSocket::ConnectingState); executed (the execution status of this line is deduced): qt_noop(); | - |
| 534 | | - |
| 535 | connectToHost(d->peerAddress, d->peerPort); executed (the execution status of this line is deduced): connectToHost(d->peerAddress, d->peerPort); | - |
| 536 | if (state() != QAbstractSocket::ConnectingState) { partially evaluated: state() != QAbstractSocket::ConnectingState| yes Evaluation Count:774 | no Evaluation Count:0 |
| 0-774 |
| 537 | // we changed states | - |
| 538 | QAbstractSocketEngine::connectionNotification(); executed (the execution status of this line is deduced): QAbstractSocketEngine::connectionNotification(); | - |
| 539 | } executed: }Execution Count:774 | 774 |
| 540 | } executed: }Execution Count:774 | 774 |
| 541 | | - |
| 542 | /*! | - |
| 543 | Connects to the remote host name given by \a name on port \a | - |
| 544 | port. When this function is called, the upper-level will not | - |
| 545 | perform a hostname lookup. | - |
| 546 | | - |
| 547 | The native socket engine does not support this operation, | - |
| 548 | but some other socket engines (notably proxy-based ones) do. | - |
| 549 | */ | - |
| 550 | bool QNativeSocketEngine::connectToHostByName(const QString &name, quint16 port) | - |
| 551 | { | - |
| 552 | Q_UNUSED(name); never executed (the execution status of this line is deduced): (void)name;; | - |
| 553 | Q_UNUSED(port); never executed (the execution status of this line is deduced): (void)port;; | - |
| 554 | Q_D(QNativeSocketEngine); never executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 555 | d->setError(QAbstractSocket::UnsupportedSocketOperationError, never executed (the execution status of this line is deduced): d->setError(QAbstractSocket::UnsupportedSocketOperationError, | - |
| 556 | QNativeSocketEnginePrivate::OperationUnsupportedErrorString); never executed (the execution status of this line is deduced): QNativeSocketEnginePrivate::OperationUnsupportedErrorString); | - |
| 557 | return false; never executed: return false; | 0 |
| 558 | } | - |
| 559 | | - |
| 560 | /*! | - |
| 561 | Binds the socket to the address \a address and port \a | - |
| 562 | port. Returns true on success; otherwise false is returned. The | - |
| 563 | port may be 0, in which case an arbitrary unused port is assigned | - |
| 564 | automatically by the operating system. | - |
| 565 | | - |
| 566 | Servers call this function to set up the server's address and | - |
| 567 | port. TCP servers must in addition call listen() after bind(). | - |
| 568 | */ | - |
| 569 | bool QNativeSocketEngine::bind(const QHostAddress &address, quint16 port) | - |
| 570 | { | - |
| 571 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 572 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::bind(), false); never executed: return false; executed: }Execution Count:670 partially evaluated: !isValid()| no Evaluation Count:0 | yes Evaluation Count:670 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:670 |
| 0-670 |
| 573 | | - |
| 574 | if (!d->checkProxy(address)) evaluated: !d->checkProxy(address)| yes Evaluation Count:1 | yes Evaluation Count:669 |
| 1-669 |
| 575 | return false; executed: return false;Execution Count:1 | 1 |
| 576 | | - |
| 577 | Q_CHECK_STATE(QNativeSocketEngine::bind(), QAbstractSocket::UnconnectedState, false); never executed: return (false); executed: }Execution Count:669 partially evaluated: d->socketState != (QAbstractSocket::UnconnectedState)| no Evaluation Count:0 | yes Evaluation Count:669 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:669 |
| 0-669 |
| 578 | | - |
| 579 | if (!d->nativeBind(address, port)) evaluated: !d->nativeBind(address, port)| yes Evaluation Count:11 | yes Evaluation Count:658 |
| 11-658 |
| 580 | return false; executed: return false;Execution Count:11 | 11 |
| 581 | | - |
| 582 | d->fetchConnectionParameters(); executed (the execution status of this line is deduced): d->fetchConnectionParameters(); | - |
| 583 | return true; executed: return true;Execution Count:658 | 658 |
| 584 | } | - |
| 585 | | - |
| 586 | /*! | - |
| 587 | Prepares a TCP server for accepting incoming connections. This | - |
| 588 | function must be called after bind(), and only by TCP sockets. | - |
| 589 | | - |
| 590 | After this function has been called, pending client connections | - |
| 591 | are detected by checking if the socket is ready for reading. This | - |
| 592 | can be done by either creating a QSocketNotifier, passing the | - |
| 593 | socket descriptor returned by socketDescriptor(), or by calling | - |
| 594 | the blocking function waitForRead(). | - |
| 595 | | - |
| 596 | Example: | - |
| 597 | \snippet code/src_network_socket_qnativesocketengine.cpp 1 | - |
| 598 | | - |
| 599 | \sa bind(), accept() | - |
| 600 | */ | - |
| 601 | bool QNativeSocketEngine::listen() | - |
| 602 | { | - |
| 603 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 604 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::listen(), false); never executed: return false; executed: }Execution Count:425 partially evaluated: !isValid()| no Evaluation Count:0 | yes Evaluation Count:425 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:425 |
| 0-425 |
| 605 | Q_CHECK_STATE(QNativeSocketEngine::listen(), QAbstractSocket::BoundState, false); never executed: return (false); executed: }Execution Count:425 partially evaluated: d->socketState != (QAbstractSocket::BoundState)| no Evaluation Count:0 | yes Evaluation Count:425 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:425 |
| 0-425 |
| 606 | Q_CHECK_TYPE(QNativeSocketEngine::listen(), QAbstractSocket::TcpSocket, false); never executed: return (false); executed: }Execution Count:425 partially evaluated: d->socketType != (QAbstractSocket::TcpSocket)| no Evaluation Count:0 | yes Evaluation Count:425 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:425 |
| 0-425 |
| 607 | | - |
| 608 | // We're using a backlog of 50. Most modern kernels support TCP | - |
| 609 | // syncookies by default, and if they do, the backlog is ignored. | - |
| 610 | // When there is no support for TCP syncookies, this value is | - |
| 611 | // fine. | - |
| 612 | return d->nativeListen(50); executed: return d->nativeListen(50);Execution Count:425 | 425 |
| 613 | } | - |
| 614 | | - |
| 615 | /*! | - |
| 616 | Accepts a pending connection from the socket, which must be in | - |
| 617 | ListeningState, and returns its socket descriptor. If no pending | - |
| 618 | connections are available, -1 is returned. | - |
| 619 | | - |
| 620 | \sa bind(), listen() | - |
| 621 | */ | - |
| 622 | int QNativeSocketEngine::accept() | - |
| 623 | { | - |
| 624 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 625 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::accept(), -1); never executed: return -1; executed: }Execution Count:920 partially evaluated: !isValid()| no Evaluation Count:0 | yes Evaluation Count:920 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:920 |
| 0-920 |
| 626 | Q_CHECK_STATE(QNativeSocketEngine::accept(), QAbstractSocket::ListeningState, false); never executed: return (false); executed: }Execution Count:920 partially evaluated: d->socketState != (QAbstractSocket::ListeningState)| no Evaluation Count:0 | yes Evaluation Count:920 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:920 |
| 0-920 |
| 627 | Q_CHECK_TYPE(QNativeSocketEngine::accept(), QAbstractSocket::TcpSocket, false); never executed: return (false); executed: }Execution Count:920 partially evaluated: d->socketType != (QAbstractSocket::TcpSocket)| no Evaluation Count:0 | yes Evaluation Count:920 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:920 |
| 0-920 |
| 628 | | - |
| 629 | return d->nativeAccept(); executed: return d->nativeAccept();Execution Count:920 | 920 |
| 630 | } | - |
| 631 | | - |
| 632 | #ifndef QT_NO_NETWORKINTERFACE | - |
| 633 | | - |
| 634 | /*! | - |
| 635 | \since 4.8 | - |
| 636 | */ | - |
| 637 | bool QNativeSocketEngine::joinMulticastGroup(const QHostAddress &groupAddress, | - |
| 638 | const QNetworkInterface &iface) | - |
| 639 | { | - |
| 640 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 641 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::joinMulticastGroup(), false); never executed: return false; executed: }Execution Count:6 partially evaluated: !isValid()| no Evaluation Count:0 | yes Evaluation Count:6 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
| 642 | Q_CHECK_STATE(QNativeSocketEngine::joinMulticastGroup(), QAbstractSocket::BoundState, false); never executed: return (false); executed: }Execution Count:6 partially evaluated: d->socketState != (QAbstractSocket::BoundState)| no Evaluation Count:0 | yes Evaluation Count:6 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
| 643 | Q_CHECK_TYPE(QNativeSocketEngine::joinMulticastGroup(), QAbstractSocket::UdpSocket, false); never executed: return (false); executed: }Execution Count:6 partially evaluated: d->socketType != (QAbstractSocket::UdpSocket)| no Evaluation Count:0 | yes Evaluation Count:6 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
| 644 | | - |
| 645 | // if the user binds a socket to an IPv6 address (or QHostAddress::Any) and | - |
| 646 | // then attempts to join an IPv4 multicast group, this won't work on | - |
| 647 | // Windows. In order to make this cross-platform, we warn & fail on all | - |
| 648 | // platforms. | - |
| 649 | if (groupAddress.protocol() == QAbstractSocket::IPv4Protocol && evaluated: groupAddress.protocol() == QAbstractSocket::IPv4Protocol| yes Evaluation Count:5 | yes Evaluation Count:1 |
| 1-5 |
| 650 | (d->socketProtocol == QAbstractSocket::IPv6Protocol || partially evaluated: d->socketProtocol == QAbstractSocket::IPv6Protocol| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 651 | d->socketProtocol == QAbstractSocket::AnyIPProtocol)) { evaluated: d->socketProtocol == QAbstractSocket::AnyIPProtocol| yes Evaluation Count:1 | yes Evaluation Count:4 |
| 1-4 |
| 652 | qWarning("QAbstractSocket: cannot bind to QHostAddress::Any (or an IPv6 address) and join an IPv4 multicast group"); executed (the execution status of this line is deduced): QMessageLogger("socket/qnativesocketengine.cpp", 652, __PRETTY_FUNCTION__).warning("QAbstractSocket: cannot bind to QHostAddress::Any (or an IPv6 address) and join an IPv4 multicast group"); | - |
| 653 | qWarning("QAbstractSocket: bind to QHostAddress::AnyIPv4 instead if you want to do this"); executed (the execution status of this line is deduced): QMessageLogger("socket/qnativesocketengine.cpp", 653, __PRETTY_FUNCTION__).warning("QAbstractSocket: bind to QHostAddress::AnyIPv4 instead if you want to do this"); | - |
| 654 | return false; executed: return false;Execution Count:1 | 1 |
| 655 | } | - |
| 656 | | - |
| 657 | return d->nativeJoinMulticastGroup(groupAddress, iface); executed: return d->nativeJoinMulticastGroup(groupAddress, iface);Execution Count:5 | 5 |
| 658 | } | - |
| 659 | | - |
| 660 | /*! | - |
| 661 | \since 4.8 | - |
| 662 | */ | - |
| 663 | bool QNativeSocketEngine::leaveMulticastGroup(const QHostAddress &groupAddress, | - |
| 664 | const QNetworkInterface &iface) | - |
| 665 | { | - |
| 666 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 667 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::leaveMulticastGroup(), false); never executed: return false; executed: }Execution Count:2 partially evaluated: !isValid()| no Evaluation Count:0 | yes Evaluation Count:2 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 668 | Q_CHECK_STATE(QNativeSocketEngine::leaveMulticastGroup(), QAbstractSocket::BoundState, false); never executed: return (false); executed: }Execution Count:2 partially evaluated: d->socketState != (QAbstractSocket::BoundState)| no Evaluation Count:0 | yes Evaluation Count:2 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 669 | Q_CHECK_TYPE(QNativeSocketEngine::leaveMulticastGroup(), QAbstractSocket::UdpSocket, false); never executed: return (false); executed: }Execution Count:2 partially evaluated: d->socketType != (QAbstractSocket::UdpSocket)| no Evaluation Count:0 | yes Evaluation Count:2 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 670 | return d->nativeLeaveMulticastGroup(groupAddress, iface); executed: return d->nativeLeaveMulticastGroup(groupAddress, iface);Execution Count:2 | 2 |
| 671 | } | - |
| 672 | | - |
| 673 | /*! \since 4.8 */ | - |
| 674 | QNetworkInterface QNativeSocketEngine::multicastInterface() const | - |
| 675 | { | - |
| 676 | Q_D(const QNativeSocketEngine); executed (the execution status of this line is deduced): const QNativeSocketEnginePrivate * const d = d_func(); | - |
| 677 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::multicastInterface(), QNetworkInterface()); never executed: return QNetworkInterface(); executed: }Execution Count:8 partially evaluated: !isValid()| no Evaluation Count:0 | yes Evaluation Count:8 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
| 678 | Q_CHECK_TYPE(QNativeSocketEngine::multicastInterface(), QAbstractSocket::UdpSocket, QNetworkInterface()); never executed: return (QNetworkInterface()); executed: }Execution Count:8 partially evaluated: d->socketType != (QAbstractSocket::UdpSocket)| no Evaluation Count:0 | yes Evaluation Count:8 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
| 679 | return d->nativeMulticastInterface(); executed: return d->nativeMulticastInterface();Execution Count:8 | 8 |
| 680 | } | - |
| 681 | | - |
| 682 | /*! \since 4.8 */ | - |
| 683 | bool QNativeSocketEngine::setMulticastInterface(const QNetworkInterface &iface) | - |
| 684 | { | - |
| 685 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 686 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::setMulticastInterface(), false); never executed: return false; executed: }Execution Count:8 partially evaluated: !isValid()| no Evaluation Count:0 | yes Evaluation Count:8 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
| 687 | Q_CHECK_TYPE(QNativeSocketEngine::setMulticastInterface(), QAbstractSocket::UdpSocket, false); never executed: return (false); executed: }Execution Count:8 partially evaluated: d->socketType != (QAbstractSocket::UdpSocket)| no Evaluation Count:0 | yes Evaluation Count:8 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
| 688 | return d->nativeSetMulticastInterface(iface); executed: return d->nativeSetMulticastInterface(iface);Execution Count:8 | 8 |
| 689 | } | - |
| 690 | | - |
| 691 | #endif // QT_NO_NETWORKINTERFACE | - |
| 692 | | - |
| 693 | /*! | - |
| 694 | Returns the number of bytes that are currently available for | - |
| 695 | reading. On error, -1 is returned. | - |
| 696 | | - |
| 697 | For UDP sockets, this function returns the accumulated size of all | - |
| 698 | pending datagrams, and it is therefore more useful for UDP sockets | - |
| 699 | to call hasPendingDatagrams() and pendingDatagramSize(). | - |
| 700 | */ | - |
| 701 | qint64 QNativeSocketEngine::bytesAvailable() const | - |
| 702 | { | - |
| 703 | Q_D(const QNativeSocketEngine); executed (the execution status of this line is deduced): const QNativeSocketEnginePrivate * const d = d_func(); | - |
| 704 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::bytesAvailable(), -1); never executed: return -1; executed: }Execution Count:33408 partially evaluated: !isValid()| no Evaluation Count:0 | yes Evaluation Count:33408 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:33408 |
| 0-33408 |
| 705 | Q_CHECK_NOT_STATE(QNativeSocketEngine::bytesAvailable(), QAbstractSocket::UnconnectedState, false); never executed: return (false); executed: }Execution Count:33408 partially evaluated: d->socketState == (QAbstractSocket::UnconnectedState)| no Evaluation Count:0 | yes Evaluation Count:33408 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:33408 |
| 0-33408 |
| 706 | | - |
| 707 | return d->nativeBytesAvailable(); executed: return d->nativeBytesAvailable();Execution Count:33408 | 33408 |
| 708 | } | - |
| 709 | | - |
| 710 | /*! | - |
| 711 | Returns true if there is at least one datagram pending. This | - |
| 712 | function is only called by UDP sockets, where a datagram can have | - |
| 713 | a size of 0. TCP sockets call bytesAvailable(). | - |
| 714 | */ | - |
| 715 | bool QNativeSocketEngine::hasPendingDatagrams() const | - |
| 716 | { | - |
| 717 | Q_D(const QNativeSocketEngine); executed (the execution status of this line is deduced): const QNativeSocketEnginePrivate * const d = d_func(); | - |
| 718 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::hasPendingDatagrams(), false); never executed: return false; executed: }Execution Count:1662511 partially evaluated: !isValid()| no Evaluation Count:0 | yes Evaluation Count:1662511 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:1662511 |
| 0-1662511 |
| 719 | Q_CHECK_NOT_STATE(QNativeSocketEngine::hasPendingDatagrams(), QAbstractSocket::UnconnectedState, false); never executed: return (false); executed: }Execution Count:1662511 partially evaluated: d->socketState == (QAbstractSocket::UnconnectedState)| no Evaluation Count:0 | yes Evaluation Count:1662511 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:1662511 |
| 0-1662511 |
| 720 | Q_CHECK_TYPE(QNativeSocketEngine::hasPendingDatagrams(), QAbstractSocket::UdpSocket, false); never executed: return (false); executed: }Execution Count:1662511 partially evaluated: d->socketType != (QAbstractSocket::UdpSocket)| no Evaluation Count:0 | yes Evaluation Count:1662511 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:1662511 |
| 0-1662511 |
| 721 | | - |
| 722 | return d->nativeHasPendingDatagrams(); executed: return d->nativeHasPendingDatagrams();Execution Count:1662511 | 1662511 |
| 723 | } | - |
| 724 | | - |
| 725 | /*! | - |
| 726 | Returns the size of the pending datagram, or -1 if no datagram is | - |
| 727 | pending. A datagram size of 0 is perfectly valid. This function is | - |
| 728 | called by UDP sockets before receiveMessage(). For TCP sockets, | - |
| 729 | call bytesAvailable(). | - |
| 730 | */ | - |
| 731 | qint64 QNativeSocketEngine::pendingDatagramSize() const | - |
| 732 | { | - |
| 733 | Q_D(const QNativeSocketEngine); executed (the execution status of this line is deduced): const QNativeSocketEnginePrivate * const d = d_func(); | - |
| 734 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::pendingDatagramSize(), -1); never executed: return -1; executed: }Execution Count:31926 partially evaluated: !isValid()| no Evaluation Count:0 | yes Evaluation Count:31926 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:31926 |
| 0-31926 |
| 735 | Q_CHECK_TYPE(QNativeSocketEngine::pendingDatagramSize(), QAbstractSocket::UdpSocket, false); never executed: return (false); executed: }Execution Count:31926 partially evaluated: d->socketType != (QAbstractSocket::UdpSocket)| no Evaluation Count:0 | yes Evaluation Count:31926 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:31926 |
| 0-31926 |
| 736 | | - |
| 737 | return d->nativePendingDatagramSize(); executed: return d->nativePendingDatagramSize();Execution Count:31926 | 31926 |
| 738 | } | - |
| 739 | | - |
| 740 | /*! | - |
| 741 | Reads up to \a maxSize bytes of a datagram from the socket, | - |
| 742 | stores it in \a data and returns the number of bytes read. The | - |
| 743 | address and port of the sender are stored in \a address and \a | - |
| 744 | port. If either of these pointers is 0, the corresponding value is | - |
| 745 | discarded. | - |
| 746 | | - |
| 747 | To avoid unnecessarily loss of data, call pendingDatagramSize() to | - |
| 748 | determine the size of the pending message before reading it. If \a | - |
| 749 | maxSize is too small, the rest of the datagram will be lost. | - |
| 750 | | - |
| 751 | Returns -1 if an error occurred. | - |
| 752 | | - |
| 753 | \sa hasPendingDatagrams() | - |
| 754 | */ | - |
| 755 | qint64 QNativeSocketEngine::readDatagram(char *data, qint64 maxSize, QHostAddress *address, | - |
| 756 | quint16 *port) | - |
| 757 | { | - |
| 758 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 759 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::readDatagram(), -1); never executed: return -1; executed: }Execution Count:990809 partially evaluated: !isValid()| no Evaluation Count:0 | yes Evaluation Count:990809 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:990809 |
| 0-990809 |
| 760 | Q_CHECK_TYPE(QNativeSocketEngine::readDatagram(), QAbstractSocket::UdpSocket, false); never executed: return (false); executed: }Execution Count:990809 partially evaluated: d->socketType != (QAbstractSocket::UdpSocket)| no Evaluation Count:0 | yes Evaluation Count:990809 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:990809 |
| 0-990809 |
| 761 | | - |
| 762 | return d->nativeReceiveDatagram(data, maxSize, address, port); executed: return d->nativeReceiveDatagram(data, maxSize, address, port);Execution Count:990809 | 990809 |
| 763 | } | - |
| 764 | | - |
| 765 | /*! | - |
| 766 | Writes a UDP datagram of size \a size bytes to the socket from | - |
| 767 | \a data to the address \a host on port \a port, and returns the | - |
| 768 | number of bytes written, or -1 if an error occurred. | - |
| 769 | | - |
| 770 | Only one datagram is sent, and if there is too much data to fit | - |
| 771 | into a single datagram, the operation will fail and error() | - |
| 772 | will return QAbstractSocket::DatagramTooLargeError. Operating systems impose an | - |
| 773 | upper limit to the size of a datagram, but this size is different | - |
| 774 | on almost all platforms. Sending large datagrams is in general | - |
| 775 | disadvised, as even if they are sent successfully, they are likely | - |
| 776 | to be fragmented before arriving at their destination. | - |
| 777 | | - |
| 778 | Experience has shown that it is in general safe to send datagrams | - |
| 779 | no larger than 512 bytes. | - |
| 780 | | - |
| 781 | \sa readDatagram() | - |
| 782 | */ | - |
| 783 | qint64 QNativeSocketEngine::writeDatagram(const char *data, qint64 size, | - |
| 784 | const QHostAddress &host, quint16 port) | - |
| 785 | { | - |
| 786 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 787 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::writeDatagram(), -1); never executed: return -1; executed: }Execution Count:324646 partially evaluated: !isValid()| no Evaluation Count:0 | yes Evaluation Count:324646 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:324646 |
| 0-324646 |
| 788 | Q_CHECK_TYPE(QNativeSocketEngine::writeDatagram(), QAbstractSocket::UdpSocket, -1); never executed: return (-1); executed: }Execution Count:324646 partially evaluated: d->socketType != (QAbstractSocket::UdpSocket)| no Evaluation Count:0 | yes Evaluation Count:324646 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:324646 |
| 0-324646 |
| 789 | return d->nativeSendDatagram(data, size, host, port); executed: return d->nativeSendDatagram(data, size, host, port);Execution Count:324646 | 324646 |
| 790 | } | - |
| 791 | | - |
| 792 | /*! | - |
| 793 | Writes a block of \a size bytes from \a data to the socket. | - |
| 794 | Returns the number of bytes written, or -1 if an error occurred. | - |
| 795 | */ | - |
| 796 | qint64 QNativeSocketEngine::write(const char *data, qint64 size) | - |
| 797 | { | - |
| 798 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 799 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::write(), -1); never executed: return -1; executed: }Execution Count:983483 partially evaluated: !isValid()| no Evaluation Count:0 | yes Evaluation Count:983483 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:983483 |
| 0-983483 |
| 800 | Q_CHECK_STATE(QNativeSocketEngine::write(), QAbstractSocket::ConnectedState, -1); never executed: return (-1); executed: }Execution Count:983483 partially evaluated: d->socketState != (QAbstractSocket::ConnectedState)| no Evaluation Count:0 | yes Evaluation Count:983483 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:983483 |
| 0-983483 |
| 801 | return d->nativeWrite(data, size); executed: return d->nativeWrite(data, size);Execution Count:983483 | 983483 |
| 802 | } | - |
| 803 | | - |
| 804 | | - |
| 805 | qint64 QNativeSocketEngine::bytesToWrite() const | - |
| 806 | { | - |
| 807 | return 0; executed: return 0;Execution Count:26827 | 26827 |
| 808 | } | - |
| 809 | | - |
| 810 | /*! | - |
| 811 | Reads up to \a maxSize bytes into \a data from the socket. | - |
| 812 | Returns the number of bytes read, or -1 if an error occurred. | - |
| 813 | */ | - |
| 814 | qint64 QNativeSocketEngine::read(char *data, qint64 maxSize) | - |
| 815 | { | - |
| 816 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 817 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::read(), -1); never executed: return -1; executed: }Execution Count:154611 partially evaluated: !isValid()| no Evaluation Count:0 | yes Evaluation Count:154611 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:154611 |
| 0-154611 |
| 818 | Q_CHECK_STATES(QNativeSocketEngine::read(), QAbstractSocket::ConnectedState, QAbstractSocket::BoundState, -1); never executed: return (-1); executed: }Execution Count:154611 partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:154611 |
partially evaluated: d->socketState != (QAbstractSocket::ConnectedState)| no Evaluation Count:0 | yes Evaluation Count:154611 |
never evaluated: d->socketState != (QAbstractSocket::BoundState) | 0-154611 |
| 819 | | - |
| 820 | qint64 readBytes = d->nativeRead(data, maxSize); executed (the execution status of this line is deduced): qint64 readBytes = d->nativeRead(data, maxSize); | - |
| 821 | | - |
| 822 | // Handle remote close | - |
| 823 | if (readBytes == 0 && d->socketType == QAbstractSocket::TcpSocket) { evaluated: readBytes == 0| yes Evaluation Count:333 | yes Evaluation Count:154278 |
partially evaluated: d->socketType == QAbstractSocket::TcpSocket| yes Evaluation Count:333 | no Evaluation Count:0 |
| 0-154278 |
| 824 | d->setError(QAbstractSocket::RemoteHostClosedError, executed (the execution status of this line is deduced): d->setError(QAbstractSocket::RemoteHostClosedError, | - |
| 825 | QNativeSocketEnginePrivate::RemoteHostClosedErrorString); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate::RemoteHostClosedErrorString); | - |
| 826 | close(); executed (the execution status of this line is deduced): close(); | - |
| 827 | return -1; executed: return -1;Execution Count:333 | 333 |
| 828 | } else if (readBytes == -1) { partially evaluated: readBytes == -1| no Evaluation Count:0 | yes Evaluation Count:154278 |
| 0-154278 |
| 829 | if (!d->hasSetSocketError) { never evaluated: !d->hasSetSocketError | 0 |
| 830 | d->hasSetSocketError = true; never executed (the execution status of this line is deduced): d->hasSetSocketError = true; | - |
| 831 | d->socketError = QAbstractSocket::NetworkError; never executed (the execution status of this line is deduced): d->socketError = QAbstractSocket::NetworkError; | - |
| 832 | d->socketErrorString = qt_error_string(); never executed (the execution status of this line is deduced): d->socketErrorString = qt_error_string(); | - |
| 833 | } | 0 |
| 834 | close(); never executed (the execution status of this line is deduced): close(); | - |
| 835 | return -1; never executed: return -1; | 0 |
| 836 | } | - |
| 837 | return readBytes; executed: return readBytes;Execution Count:154278 | 154278 |
| 838 | } | - |
| 839 | | - |
| 840 | /*! | - |
| 841 | Closes the socket. In order to use the socket again, initialize() | - |
| 842 | must be called. | - |
| 843 | */ | - |
| 844 | void QNativeSocketEngine::close() | - |
| 845 | { | - |
| 846 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 847 | if (d->readNotifier) evaluated: d->readNotifier| yes Evaluation Count:2459 | yes Evaluation Count:4613 |
| 2459-4613 |
| 848 | d->readNotifier->setEnabled(false); executed: d->readNotifier->setEnabled(false);Execution Count:2459 | 2459 |
| 849 | if (d->writeNotifier) evaluated: d->writeNotifier| yes Evaluation Count:2326 | yes Evaluation Count:4746 |
| 2326-4746 |
| 850 | d->writeNotifier->setEnabled(false); executed: d->writeNotifier->setEnabled(false);Execution Count:2326 | 2326 |
| 851 | if (d->exceptNotifier) partially evaluated: d->exceptNotifier| no Evaluation Count:0 | yes Evaluation Count:7072 |
| 0-7072 |
| 852 | d->exceptNotifier->setEnabled(false); never executed: d->exceptNotifier->setEnabled(false); | 0 |
| 853 | | - |
| 854 | if(d->socketDescriptor != -1) { evaluated: d->socketDescriptor != -1| yes Evaluation Count:3371 | yes Evaluation Count:3701 |
| 3371-3701 |
| 855 | d->nativeClose(); executed (the execution status of this line is deduced): d->nativeClose(); | - |
| 856 | d->socketDescriptor = -1; executed (the execution status of this line is deduced): d->socketDescriptor = -1; | - |
| 857 | } executed: }Execution Count:3371 | 3371 |
| 858 | d->socketState = QAbstractSocket::UnconnectedState; executed (the execution status of this line is deduced): d->socketState = QAbstractSocket::UnconnectedState; | - |
| 859 | d->hasSetSocketError = false; executed (the execution status of this line is deduced): d->hasSetSocketError = false; | - |
| 860 | d->localPort = 0; executed (the execution status of this line is deduced): d->localPort = 0; | - |
| 861 | d->localAddress.clear(); executed (the execution status of this line is deduced): d->localAddress.clear(); | - |
| 862 | d->peerPort = 0; executed (the execution status of this line is deduced): d->peerPort = 0; | - |
| 863 | d->peerAddress.clear(); executed (the execution status of this line is deduced): d->peerAddress.clear(); | - |
| 864 | if (d->readNotifier) { evaluated: d->readNotifier| yes Evaluation Count:2458 | yes Evaluation Count:4613 |
| 2458-4613 |
| 865 | qDeleteInEventHandler(d->readNotifier); executed (the execution status of this line is deduced): qDeleteInEventHandler(d->readNotifier); | - |
| 866 | d->readNotifier = 0; executed (the execution status of this line is deduced): d->readNotifier = 0; | - |
| 867 | } executed: }Execution Count:2459 | 2459 |
| 868 | if (d->writeNotifier) { evaluated: d->writeNotifier| yes Evaluation Count:2326 | yes Evaluation Count:4746 |
| 2326-4746 |
| 869 | qDeleteInEventHandler(d->writeNotifier); executed (the execution status of this line is deduced): qDeleteInEventHandler(d->writeNotifier); | - |
| 870 | d->writeNotifier = 0; executed (the execution status of this line is deduced): d->writeNotifier = 0; | - |
| 871 | } executed: }Execution Count:2326 | 2326 |
| 872 | if (d->exceptNotifier) { partially evaluated: d->exceptNotifier| no Evaluation Count:0 | yes Evaluation Count:7072 |
| 0-7072 |
| 873 | qDeleteInEventHandler(d->exceptNotifier); never executed (the execution status of this line is deduced): qDeleteInEventHandler(d->exceptNotifier); | - |
| 874 | d->exceptNotifier = 0; never executed (the execution status of this line is deduced): d->exceptNotifier = 0; | - |
| 875 | } | 0 |
| 876 | } executed: }Execution Count:7072 | 7072 |
| 877 | | - |
| 878 | /*! | - |
| 879 | Waits for \a msecs milliseconds or until the socket is ready for | - |
| 880 | reading. If \a timedOut is not 0 and \a msecs milliseconds have | - |
| 881 | passed, the value of \a timedOut is set to true. | - |
| 882 | | - |
| 883 | Returns true if data is available for reading; otherwise returns | - |
| 884 | false. | - |
| 885 | | - |
| 886 | This is a blocking function call; its use is disadvised in a | - |
| 887 | single threaded application, as the whole thread will stop | - |
| 888 | responding until the function returns. waitForRead() is most | - |
| 889 | useful when there is no event loop available. The general approach | - |
| 890 | is to create a QSocketNotifier, passing the socket descriptor | - |
| 891 | returned by socketDescriptor() to its constructor. | - |
| 892 | */ | - |
| 893 | bool QNativeSocketEngine::waitForRead(int msecs, bool *timedOut) | - |
| 894 | { | - |
| 895 | Q_D(const QNativeSocketEngine); executed (the execution status of this line is deduced): const QNativeSocketEnginePrivate * const d = d_func(); | - |
| 896 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::waitForRead(), false); never executed: return false; executed: }Execution Count:282 partially evaluated: !isValid()| no Evaluation Count:0 | yes Evaluation Count:282 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:282 |
| 0-282 |
| 897 | Q_CHECK_NOT_STATE(QNativeSocketEngine::waitForRead(), never executed: return (false); executed: }Execution Count:282 partially evaluated: d->socketState == (QAbstractSocket::UnconnectedState)| no Evaluation Count:0 | yes Evaluation Count:282 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:282 |
| 0-282 |
| 898 | QAbstractSocket::UnconnectedState, false); | - |
| 899 | | - |
| 900 | if (timedOut) evaluated: timedOut| yes Evaluation Count:2 | yes Evaluation Count:280 |
| 2-280 |
| 901 | *timedOut = false; executed: *timedOut = false;Execution Count:2 | 2 |
| 902 | | - |
| 903 | int ret = d->nativeSelect(msecs, true); executed (the execution status of this line is deduced): int ret = d->nativeSelect(msecs, true); | - |
| 904 | if (ret == 0) { evaluated: ret == 0| yes Evaluation Count:35 | yes Evaluation Count:247 |
| 35-247 |
| 905 | if (timedOut) evaluated: timedOut| yes Evaluation Count:1 | yes Evaluation Count:34 |
| 1-34 |
| 906 | *timedOut = true; executed: *timedOut = true;Execution Count:1 | 1 |
| 907 | d->setError(QAbstractSocket::SocketTimeoutError, executed (the execution status of this line is deduced): d->setError(QAbstractSocket::SocketTimeoutError, | - |
| 908 | QNativeSocketEnginePrivate::TimeOutErrorString); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate::TimeOutErrorString); | - |
| 909 | d->hasSetSocketError = false; // A timeout error is temporary in waitFor functions executed (the execution status of this line is deduced): d->hasSetSocketError = false; | - |
| 910 | return false; executed: return false;Execution Count:35 | 35 |
| 911 | } else if (state() == QAbstractSocket::ConnectingState) { partially evaluated: state() == QAbstractSocket::ConnectingState| no Evaluation Count:0 | yes Evaluation Count:247 |
| 0-247 |
| 912 | connectToHost(d->peerAddress, d->peerPort); never executed (the execution status of this line is deduced): connectToHost(d->peerAddress, d->peerPort); | - |
| 913 | } | 0 |
| 914 | | - |
| 915 | return ret > 0; executed: return ret > 0;Execution Count:247 | 247 |
| 916 | } | - |
| 917 | | - |
| 918 | /*! | - |
| 919 | Waits for \a msecs milliseconds or until the socket is ready for | - |
| 920 | writing. If \a timedOut is not 0 and \a msecs milliseconds have | - |
| 921 | passed, the value of \a timedOut is set to true. | - |
| 922 | | - |
| 923 | Returns true if data is available for writing; otherwise returns | - |
| 924 | false. | - |
| 925 | | - |
| 926 | This is a blocking function call; its use is disadvised in a | - |
| 927 | single threaded application, as the whole thread will stop | - |
| 928 | responding until the function returns. waitForWrite() is most | - |
| 929 | useful when there is no event loop available. The general approach | - |
| 930 | is to create a QSocketNotifier, passing the socket descriptor | - |
| 931 | returned by socketDescriptor() to its constructor. | - |
| 932 | */ | - |
| 933 | bool QNativeSocketEngine::waitForWrite(int msecs, bool *timedOut) | - |
| 934 | { | - |
| 935 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 936 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::waitForWrite(), false); never executed: return false; executed: }Execution Count:421 partially evaluated: !isValid()| no Evaluation Count:0 | yes Evaluation Count:421 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:421 |
| 0-421 |
| 937 | Q_CHECK_NOT_STATE(QNativeSocketEngine::waitForWrite(), never executed: return (false); executed: }Execution Count:421 partially evaluated: d->socketState == (QAbstractSocket::UnconnectedState)| no Evaluation Count:0 | yes Evaluation Count:421 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:421 |
| 0-421 |
| 938 | QAbstractSocket::UnconnectedState, false); | - |
| 939 | | - |
| 940 | if (timedOut) partially evaluated: timedOut| yes Evaluation Count:421 | no Evaluation Count:0 |
| 0-421 |
| 941 | *timedOut = false; executed: *timedOut = false;Execution Count:421 | 421 |
| 942 | | - |
| 943 | int ret = d->nativeSelect(msecs, false); executed (the execution status of this line is deduced): int ret = d->nativeSelect(msecs, false); | - |
| 944 | // On Windows, the socket is in connected state if a call to | - |
| 945 | // select(writable) is successful. In this case we should not | - |
| 946 | // issue a second call to WSAConnect() | - |
| 947 | #if defined (Q_OS_WIN) | - |
| 948 | if (ret > 0) { | - |
| 949 | setState(QAbstractSocket::ConnectedState); | - |
| 950 | d_func()->fetchConnectionParameters(); | - |
| 951 | return true; | - |
| 952 | } else { | - |
| 953 | int value = 0; | - |
| 954 | int valueSize = sizeof(value); | - |
| 955 | if (::getsockopt(d->socketDescriptor, SOL_SOCKET, SO_ERROR, (char *) &value, &valueSize) == 0) { | - |
| 956 | if (value == WSAECONNREFUSED) { | - |
| 957 | d->setError(QAbstractSocket::ConnectionRefusedError, QNativeSocketEnginePrivate::ConnectionRefusedErrorString); | - |
| 958 | d->socketState = QAbstractSocket::UnconnectedState; | - |
| 959 | return false; | - |
| 960 | } else if (value == WSAETIMEDOUT) { | - |
| 961 | d->setError(QAbstractSocket::NetworkError, QNativeSocketEnginePrivate::ConnectionTimeOutErrorString); | - |
| 962 | d->socketState = QAbstractSocket::UnconnectedState; | - |
| 963 | return false; | - |
| 964 | } else if (value == WSAEHOSTUNREACH) { | - |
| 965 | d->setError(QAbstractSocket::NetworkError, QNativeSocketEnginePrivate::HostUnreachableErrorString); | - |
| 966 | d->socketState = QAbstractSocket::UnconnectedState; | - |
| 967 | return false; | - |
| 968 | } | - |
| 969 | } | - |
| 970 | } | - |
| 971 | #endif | - |
| 972 | | - |
| 973 | if (ret == 0) { partially evaluated: ret == 0| no Evaluation Count:0 | yes Evaluation Count:421 |
| 0-421 |
| 974 | if (timedOut) never evaluated: timedOut | 0 |
| 975 | *timedOut = true; never executed: *timedOut = true; | 0 |
| 976 | d->setError(QAbstractSocket::SocketTimeoutError, never executed (the execution status of this line is deduced): d->setError(QAbstractSocket::SocketTimeoutError, | - |
| 977 | QNativeSocketEnginePrivate::TimeOutErrorString); never executed (the execution status of this line is deduced): QNativeSocketEnginePrivate::TimeOutErrorString); | - |
| 978 | d->hasSetSocketError = false; // A timeout error is temporary in waitFor functions never executed (the execution status of this line is deduced): d->hasSetSocketError = false; | - |
| 979 | return false; never executed: return false; | 0 |
| 980 | } else if (state() == QAbstractSocket::ConnectingState) { partially evaluated: state() == QAbstractSocket::ConnectingState| yes Evaluation Count:421 | no Evaluation Count:0 |
| 0-421 |
| 981 | connectToHost(d->peerAddress, d->peerPort); executed (the execution status of this line is deduced): connectToHost(d->peerAddress, d->peerPort); | - |
| 982 | } executed: }Execution Count:421 | 421 |
| 983 | | - |
| 984 | return ret > 0; executed: return ret > 0;Execution Count:421 | 421 |
| 985 | } | - |
| 986 | | - |
| 987 | bool QNativeSocketEngine::waitForReadOrWrite(bool *readyToRead, bool *readyToWrite, | - |
| 988 | bool checkRead, bool checkWrite, | - |
| 989 | int msecs, bool *timedOut) | - |
| 990 | { | - |
| 991 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 992 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::waitForWrite(), false); never executed: return false; executed: }Execution Count:18314 partially evaluated: !isValid()| no Evaluation Count:0 | yes Evaluation Count:18314 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:18314 |
| 0-18314 |
| 993 | Q_CHECK_NOT_STATE(QNativeSocketEngine::waitForReadOrWrite(), never executed: return (false); executed: }Execution Count:18315 partially evaluated: d->socketState == (QAbstractSocket::UnconnectedState)| no Evaluation Count:0 | yes Evaluation Count:18315 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:18315 |
| 0-18315 |
| 994 | QAbstractSocket::UnconnectedState, false); | - |
| 995 | | - |
| 996 | int ret = d->nativeSelect(msecs, checkRead, checkWrite, readyToRead, readyToWrite); executed (the execution status of this line is deduced): int ret = d->nativeSelect(msecs, checkRead, checkWrite, readyToRead, readyToWrite); | - |
| 997 | // On Windows, the socket is in connected state if a call to | - |
| 998 | // select(writable) is successful. In this case we should not | - |
| 999 | // issue a second call to WSAConnect() | - |
| 1000 | #if defined (Q_OS_WIN) | - |
| 1001 | if (checkWrite && ((readyToWrite && *readyToWrite) || !readyToWrite) && ret > 0) { | - |
| 1002 | setState(QAbstractSocket::ConnectedState); | - |
| 1003 | d_func()->fetchConnectionParameters(); | - |
| 1004 | return true; | - |
| 1005 | } else { | - |
| 1006 | int value = 0; | - |
| 1007 | int valueSize = sizeof(value); | - |
| 1008 | if (::getsockopt(d->socketDescriptor, SOL_SOCKET, SO_ERROR, (char *) &value, &valueSize) == 0) { | - |
| 1009 | if (value == WSAECONNREFUSED) { | - |
| 1010 | d->setError(QAbstractSocket::ConnectionRefusedError, QNativeSocketEnginePrivate::ConnectionRefusedErrorString); | - |
| 1011 | d->socketState = QAbstractSocket::UnconnectedState; | - |
| 1012 | return false; | - |
| 1013 | } else if (value == WSAETIMEDOUT) { | - |
| 1014 | d->setError(QAbstractSocket::NetworkError, QNativeSocketEnginePrivate::ConnectionTimeOutErrorString); | - |
| 1015 | d->socketState = QAbstractSocket::UnconnectedState; | - |
| 1016 | return false; | - |
| 1017 | } else if (value == WSAEHOSTUNREACH) { | - |
| 1018 | d->setError(QAbstractSocket::NetworkError, QNativeSocketEnginePrivate::HostUnreachableErrorString); | - |
| 1019 | d->socketState = QAbstractSocket::UnconnectedState; | - |
| 1020 | return false; | - |
| 1021 | } | - |
| 1022 | } | - |
| 1023 | } | - |
| 1024 | #endif | - |
| 1025 | if (ret == 0) { evaluated: ret == 0| yes Evaluation Count:31 | yes Evaluation Count:18284 |
| 31-18284 |
| 1026 | if (timedOut) partially evaluated: timedOut| no Evaluation Count:0 | yes Evaluation Count:31 |
| 0-31 |
| 1027 | *timedOut = true; never executed: *timedOut = true; | 0 |
| 1028 | d->setError(QAbstractSocket::SocketTimeoutError, executed (the execution status of this line is deduced): d->setError(QAbstractSocket::SocketTimeoutError, | - |
| 1029 | QNativeSocketEnginePrivate::TimeOutErrorString); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate::TimeOutErrorString); | - |
| 1030 | d->hasSetSocketError = false; // A timeout error is temporary in waitFor functions executed (the execution status of this line is deduced): d->hasSetSocketError = false; | - |
| 1031 | return false; executed: return false;Execution Count:31 | 31 |
| 1032 | } else if (state() == QAbstractSocket::ConnectingState) { partially evaluated: state() == QAbstractSocket::ConnectingState| no Evaluation Count:0 | yes Evaluation Count:18284 |
| 0-18284 |
| 1033 | connectToHost(d->peerAddress, d->peerPort); never executed (the execution status of this line is deduced): connectToHost(d->peerAddress, d->peerPort); | - |
| 1034 | } | 0 |
| 1035 | | - |
| 1036 | return ret > 0; executed: return ret > 0;Execution Count:18284 | 18284 |
| 1037 | } | - |
| 1038 | | - |
| 1039 | /*! | - |
| 1040 | Returns the size of the operating system's socket receive | - |
| 1041 | buffer. Depending on the operating system, this size may be | - |
| 1042 | different from what has been set earlier with | - |
| 1043 | setReceiveBufferSize(). | - |
| 1044 | */ | - |
| 1045 | qint64 QNativeSocketEngine::receiveBufferSize() const | - |
| 1046 | { | - |
| 1047 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::receiveBufferSize(), -1); never executed: return -1; never executed: } never evaluated: !isValid() never evaluated: 0 | 0 |
| 1048 | return option(ReceiveBufferSocketOption); never executed: return option(ReceiveBufferSocketOption); | 0 |
| 1049 | } | - |
| 1050 | | - |
| 1051 | /*! | - |
| 1052 | Sets the size of the operating system receive buffer to \a size. | - |
| 1053 | | - |
| 1054 | For clients, this should be set before connectToHost() is called; | - |
| 1055 | otherwise it will have no effect. For servers, it should be called | - |
| 1056 | before listen(). | - |
| 1057 | | - |
| 1058 | The operating system receive buffer size effectively limits two | - |
| 1059 | things: how much data can be in transit at any one moment, and how | - |
| 1060 | much data can be received in one iteration of the main event loop. | - |
| 1061 | Setting the size of the receive buffer may have an impact on the | - |
| 1062 | socket's performance. | - |
| 1063 | | - |
| 1064 | The default value is operating system-dependent. | - |
| 1065 | */ | - |
| 1066 | void QNativeSocketEngine::setReceiveBufferSize(qint64 size) | - |
| 1067 | { | - |
| 1068 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::setReceiveBufferSize(), Q_VOID); never executed: return ; never executed: } never evaluated: !isValid() never evaluated: 0 | 0 |
| 1069 | setOption(ReceiveBufferSocketOption, size); never executed (the execution status of this line is deduced): setOption(ReceiveBufferSocketOption, size); | - |
| 1070 | } | 0 |
| 1071 | | - |
| 1072 | /*! | - |
| 1073 | Returns the size of the operating system send buffer. Depending on | - |
| 1074 | the operating system, this size may be different from what has | - |
| 1075 | been set earlier with setSendBufferSize(). | - |
| 1076 | */ | - |
| 1077 | qint64 QNativeSocketEngine::sendBufferSize() const | - |
| 1078 | { | - |
| 1079 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::setSendBufferSize(), -1); never executed: return -1; never executed: } never evaluated: !isValid() never evaluated: 0 | 0 |
| 1080 | return option(SendBufferSocketOption); never executed: return option(SendBufferSocketOption); | 0 |
| 1081 | } | - |
| 1082 | | - |
| 1083 | /*! | - |
| 1084 | Sets the size of the operating system send buffer to \a size. | - |
| 1085 | | - |
| 1086 | The operating system send buffer size effectively limits how much | - |
| 1087 | data can be in transit at any one moment. Setting the size of the | - |
| 1088 | send buffer may have an impact on the socket's performance. | - |
| 1089 | | - |
| 1090 | The default value is operating system-dependent. | - |
| 1091 | */ | - |
| 1092 | void QNativeSocketEngine::setSendBufferSize(qint64 size) | - |
| 1093 | { | - |
| 1094 | Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::setSendBufferSize(), Q_VOID); never executed: return ; never executed: } never evaluated: !isValid() never evaluated: 0 | 0 |
| 1095 | setOption(SendBufferSocketOption, size); never executed (the execution status of this line is deduced): setOption(SendBufferSocketOption, size); | - |
| 1096 | } | 0 |
| 1097 | | - |
| 1098 | | - |
| 1099 | /*! | - |
| 1100 | Sets the option \a option to the value \a value. | - |
| 1101 | */ | - |
| 1102 | bool QNativeSocketEngine::setOption(SocketOption option, int value) | - |
| 1103 | { | - |
| 1104 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 1105 | return d->setOption(option, value); executed: return d->setOption(option, value);Execution Count:7277 | 7277 |
| 1106 | } | - |
| 1107 | | - |
| 1108 | /*! | - |
| 1109 | Returns the value of the option \a socketOption. | - |
| 1110 | */ | - |
| 1111 | int QNativeSocketEngine::option(SocketOption socketOption) const | - |
| 1112 | { | - |
| 1113 | Q_D(const QNativeSocketEngine); executed (the execution status of this line is deduced): const QNativeSocketEnginePrivate * const d = d_func(); | - |
| 1114 | return d->option(socketOption); executed: return d->option(socketOption);Execution Count:26 | 26 |
| 1115 | } | - |
| 1116 | | - |
| 1117 | bool QNativeSocketEngine::isReadNotificationEnabled() const | - |
| 1118 | { | - |
| 1119 | Q_D(const QNativeSocketEngine); executed (the execution status of this line is deduced): const QNativeSocketEnginePrivate * const d = d_func(); | - |
| 1120 | return d->readNotifier && d->readNotifier->isEnabled(); executed: return d->readNotifier && d->readNotifier->isEnabled();Execution Count:442147 | 442147 |
| 1121 | } | - |
| 1122 | | - |
| 1123 | /* | - |
| 1124 | \internal | - |
| 1125 | \class QReadNotifier | - |
| 1126 | \brief The QReadNotifer class is used to improve performance. | - |
| 1127 | | - |
| 1128 | QReadNotifier is a private class used for performance reasons vs | - |
| 1129 | connecting to the QSocketNotifier activated() signal. | - |
| 1130 | */ | - |
| 1131 | class QReadNotifier : public QSocketNotifier | - |
| 1132 | { | - |
| 1133 | public: | - |
| 1134 | QReadNotifier(qintptr fd, QNativeSocketEngine *parent) | - |
| 1135 | : QSocketNotifier(fd, QSocketNotifier::Read, parent) | - |
| 1136 | { engine = parent; } executed: }Execution Count:2461 | 2461 |
| 1137 | | - |
| 1138 | protected: | - |
| 1139 | bool event(QEvent *); | - |
| 1140 | | - |
| 1141 | QNativeSocketEngine *engine; | - |
| 1142 | }; | - |
| 1143 | | - |
| 1144 | bool QReadNotifier::event(QEvent *e) | - |
| 1145 | { | - |
| 1146 | if (e->type() == QEvent::SockAct) { evaluated: e->type() == QEvent::SockAct| yes Evaluation Count:9576 | yes Evaluation Count:8 |
| 8-9576 |
| 1147 | engine->readNotification(); executed (the execution status of this line is deduced): engine->readNotification(); | - |
| 1148 | return true; executed: return true;Execution Count:9576 | 9576 |
| 1149 | } else if (e->type() == QEvent::SockClose) { partially evaluated: e->type() == QEvent::SockClose| no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
| 1150 | engine->closeNotification(); never executed (the execution status of this line is deduced): engine->closeNotification(); | - |
| 1151 | return true; never executed: return true; | 0 |
| 1152 | } | - |
| 1153 | return QSocketNotifier::event(e); executed: return QSocketNotifier::event(e);Execution Count:8 | 8 |
| 1154 | } | - |
| 1155 | | - |
| 1156 | /* | - |
| 1157 | \internal | - |
| 1158 | \class QWriteNotifier | - |
| 1159 | \brief The QWriteNotifer class is used to improve performance. | - |
| 1160 | | - |
| 1161 | QWriteNotifier is a private class used for performance reasons vs | - |
| 1162 | connecting to the QSocketNotifier activated() signal. | - |
| 1163 | */ | - |
| 1164 | class QWriteNotifier : public QSocketNotifier | - |
| 1165 | { | - |
| 1166 | public: | - |
| 1167 | QWriteNotifier(int fd, QNativeSocketEngine *parent) | - |
| 1168 | : QSocketNotifier(fd, QSocketNotifier::Write, parent) { engine = parent; } executed: }Execution Count:2328 | 2328 |
| 1169 | | - |
| 1170 | protected: | - |
| 1171 | bool event(QEvent *); | - |
| 1172 | | - |
| 1173 | QNativeSocketEngine *engine; | - |
| 1174 | }; | - |
| 1175 | | - |
| 1176 | bool QWriteNotifier::event(QEvent *e) | - |
| 1177 | { | - |
| 1178 | if (e->type() == QEvent::SockAct) { evaluated: e->type() == QEvent::SockAct| yes Evaluation Count:8026 | yes Evaluation Count:2 |
| 2-8026 |
| 1179 | if (engine->state() == QAbstractSocket::ConnectingState) evaluated: engine->state() == QAbstractSocket::ConnectingState| yes Evaluation Count:774 | yes Evaluation Count:7252 |
| 774-7252 |
| 1180 | engine->connectionNotification(); executed: engine->connectionNotification();Execution Count:774 | 774 |
| 1181 | else | - |
| 1182 | engine->writeNotification(); executed: engine->writeNotification();Execution Count:7252 | 7252 |
| 1183 | return true; executed: return true;Execution Count:8026 | 8026 |
| 1184 | } | - |
| 1185 | return QSocketNotifier::event(e); executed: return QSocketNotifier::event(e);Execution Count:2 | 2 |
| 1186 | } | - |
| 1187 | | - |
| 1188 | class QExceptionNotifier : public QSocketNotifier | - |
| 1189 | { | - |
| 1190 | public: | - |
| 1191 | QExceptionNotifier(int fd, QNativeSocketEngine *parent) | - |
| 1192 | : QSocketNotifier(fd, QSocketNotifier::Exception, parent) { engine = parent; } | 0 |
| 1193 | | - |
| 1194 | protected: | - |
| 1195 | bool event(QEvent *); | - |
| 1196 | | - |
| 1197 | QNativeSocketEngine *engine; | - |
| 1198 | }; | - |
| 1199 | | - |
| 1200 | bool QExceptionNotifier::event(QEvent *e) | - |
| 1201 | { | - |
| 1202 | if (e->type() == QEvent::SockAct) { never evaluated: e->type() == QEvent::SockAct | 0 |
| 1203 | if (engine->state() == QAbstractSocket::ConnectingState) never evaluated: engine->state() == QAbstractSocket::ConnectingState | 0 |
| 1204 | engine->connectionNotification(); never executed: engine->connectionNotification(); | 0 |
| 1205 | else | - |
| 1206 | engine->exceptionNotification(); never executed: engine->exceptionNotification(); | 0 |
| 1207 | return true; never executed: return true; | 0 |
| 1208 | } | - |
| 1209 | return QSocketNotifier::event(e); never executed: return QSocketNotifier::event(e); | 0 |
| 1210 | } | - |
| 1211 | | - |
| 1212 | void QNativeSocketEngine::setReadNotificationEnabled(bool enable) | - |
| 1213 | { | - |
| 1214 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 1215 | if (d->readNotifier) { evaluated: d->readNotifier| yes Evaluation Count:1005709 | yes Evaluation Count:3353 |
| 3353-1005709 |
| 1216 | d->readNotifier->setEnabled(enable); executed (the execution status of this line is deduced): d->readNotifier->setEnabled(enable); | - |
| 1217 | } else if (enable && d->threadData->eventDispatcher) { executed: }Execution Count:1005709 evaluated: enable| yes Evaluation Count:2461 | yes Evaluation Count:892 |
partially evaluated: d->threadData->eventDispatcher| yes Evaluation Count:2461 | no Evaluation Count:0 |
| 0-1005709 |
| 1218 | d->readNotifier = new QReadNotifier(d->socketDescriptor, this); executed (the execution status of this line is deduced): d->readNotifier = new QReadNotifier(d->socketDescriptor, this); | - |
| 1219 | d->readNotifier->setEnabled(true); executed (the execution status of this line is deduced): d->readNotifier->setEnabled(true); | - |
| 1220 | } executed: }Execution Count:2461 | 2461 |
| 1221 | } | - |
| 1222 | | - |
| 1223 | bool QNativeSocketEngine::isWriteNotificationEnabled() const | - |
| 1224 | { | - |
| 1225 | Q_D(const QNativeSocketEngine); executed (the execution status of this line is deduced): const QNativeSocketEnginePrivate * const d = d_func(); | - |
| 1226 | return d->writeNotifier && d->writeNotifier->isEnabled(); executed: return d->writeNotifier && d->writeNotifier->isEnabled();Execution Count:18490 | 18490 |
| 1227 | } | - |
| 1228 | | - |
| 1229 | void QNativeSocketEngine::setWriteNotificationEnabled(bool enable) | - |
| 1230 | { | - |
| 1231 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 1232 | if (d->writeNotifier) { evaluated: d->writeNotifier| yes Evaluation Count:50556 | yes Evaluation Count:2328 |
| 2328-50556 |
| 1233 | d->writeNotifier->setEnabled(enable); executed (the execution status of this line is deduced): d->writeNotifier->setEnabled(enable); | - |
| 1234 | } else if (enable && d->threadData->eventDispatcher) { executed: }Execution Count:50556 partially evaluated: enable| yes Evaluation Count:2328 | no Evaluation Count:0 |
partially evaluated: d->threadData->eventDispatcher| yes Evaluation Count:2328 | no Evaluation Count:0 |
| 0-50556 |
| 1235 | d->writeNotifier = new QWriteNotifier(d->socketDescriptor, this); executed (the execution status of this line is deduced): d->writeNotifier = new QWriteNotifier(d->socketDescriptor, this); | - |
| 1236 | d->writeNotifier->setEnabled(true); executed (the execution status of this line is deduced): d->writeNotifier->setEnabled(true); | - |
| 1237 | } executed: }Execution Count:2328 | 2328 |
| 1238 | } | - |
| 1239 | | - |
| 1240 | bool QNativeSocketEngine::isExceptionNotificationEnabled() const | - |
| 1241 | { | - |
| 1242 | Q_D(const QNativeSocketEngine); executed (the execution status of this line is deduced): const QNativeSocketEnginePrivate * const d = d_func(); | - |
| 1243 | return d->exceptNotifier && d->exceptNotifier->isEnabled(); executed: return d->exceptNotifier && d->exceptNotifier->isEnabled();Execution Count:167 | 167 |
| 1244 | } | - |
| 1245 | | - |
| 1246 | void QNativeSocketEngine::setExceptionNotificationEnabled(bool enable) | - |
| 1247 | { | - |
| 1248 | Q_D(QNativeSocketEngine); executed (the execution status of this line is deduced): QNativeSocketEnginePrivate * const d = d_func(); | - |
| 1249 | if (d->exceptNotifier) { partially evaluated: d->exceptNotifier| no Evaluation Count:0 | yes Evaluation Count:334 |
| 0-334 |
| 1250 | d->exceptNotifier->setEnabled(enable); never executed (the execution status of this line is deduced): d->exceptNotifier->setEnabled(enable); | - |
| 1251 | } else if (enable && d->threadData->eventDispatcher) { never executed: } partially evaluated: enable| no Evaluation Count:0 | yes Evaluation Count:334 |
never evaluated: d->threadData->eventDispatcher | 0-334 |
| 1252 | d->exceptNotifier = new QExceptionNotifier(d->socketDescriptor, this); never executed (the execution status of this line is deduced): d->exceptNotifier = new QExceptionNotifier(d->socketDescriptor, this); | - |
| 1253 | d->exceptNotifier->setEnabled(true); never executed (the execution status of this line is deduced): d->exceptNotifier->setEnabled(true); | - |
| 1254 | } | 0 |
| 1255 | } | - |
| 1256 | | - |
| 1257 | QT_END_NAMESPACE | - |
| 1258 | | - |
| | |