Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qhttpsocketengine.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include "qtcpsocket.h"
6#include "qhostaddress.h"
7#include "qurl.h"
8#include "private/qhttpnetworkreply_p.h"
9#include "private/qiodevice_p.h"
10#include "qelapsedtimer.h"
11#include "qnetworkinterface.h"
12
13#if !defined(QT_NO_NETWORKPROXY)
14#include <qdebug.h>
15
17
18using namespace Qt::StringLiterals;
19
20#define DEBUG
21
24{
25}
26
28{
29}
30
32{
35 return false;
36
39 d->socket = new QTcpSocket(this);
40 d->reply = new QHttpNetworkReply(QUrl(), this);
41
42 // Explicitly disable proxying on the proxy socket itself to avoid
43 // unwanted recursion.
44 d->socket->setProxy(QNetworkProxy::NoProxy);
45
46 // Intercept all the signals.
47 connect(d->socket, SIGNAL(connected()),
50 connect(d->socket, SIGNAL(disconnected()),
53 connect(d->socket, SIGNAL(readyRead()),
59 connect(d->socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)),
62 connect(d->socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
65
66 return true;
67}
68
70{
71 return false;
72}
73
75{
77 d->proxy = proxy;
78 QString user = proxy.user();
79 if (!user.isEmpty())
80 d->authenticator.setUser(user);
81 QString password = proxy.password();
82 if (!password.isEmpty())
83 d->authenticator.setPassword(password);
84}
85
87{
88 Q_D(const QHttpSocketEngine);
89 return d->socket ? d->socket->socketDescriptor() : -1;
90}
91
93{
94 Q_D(const QHttpSocketEngine);
95 return d->socket;
96}
97
99{
101
102 d->credentialsSent = false;
103
104 // If the handshake is done, enter ConnectedState state and return true.
105 if (d->state == Connected) {
106 qWarning("QHttpSocketEngine::connectToHost: called when already connected");
108 return true;
109 }
110
111 if (d->state == ConnectSent && d->socketState != QAbstractSocket::ConnectedState)
113
114 // Handshake isn't done. If unconnected, start connecting.
115 if (d->state == None && d->socket->state() == QAbstractSocket::UnconnectedState) {
117 //limit buffer in internal socket, data is buffered in the external socket under application control
118 d->socket->setReadBufferSize(65536);
119 d->socket->connectToHost(d->proxy.hostName(), d->proxy.port());
120 }
121
122 // If connected (might happen right away, at least for localhost services
123 // on some BSD systems), there might already be bytes available.
124 if (bytesAvailable())
126
127 return d->socketState == QAbstractSocket::ConnectedState;
128}
129
131{
133
136 d->peerName.clear();
137
138 return connectInternal();
139}
140
142{
144
147 d->peerName = hostname;
148
149 return connectInternal();
150}
151
153{
154 qWarning("Operation is not supported");
155 setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
156 return false;
157}
158
160{
161 Q_UNUSED(backlog);
162 qWarning("Operation is not supported");
163 setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
164 return false;
165}
166
168{
169 qWarning("Operation is not supported");
170 setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
171 return -1;
172}
173
175{
177 if (d->socket) {
178 d->socket->close();
179 delete d->socket;
180 d->socket = nullptr;
181 }
182}
183
185{
186 Q_D(const QHttpSocketEngine);
187 return d->socket ? d->socket->bytesAvailable() : 0;
188}
189
191{
193 qint64 bytesRead = d->socket->read(data, maxlen);
194
195 if (d->socket->state() == QAbstractSocket::UnconnectedState
196 && d->socket->bytesAvailable() == 0) {
197 emitReadNotification();
198 }
199
200 if (bytesRead == -1) {
201 // If nothing has been read so far, and the direct socket read
202 // failed, return the socket's error. Otherwise, fall through and
203 // return as much as we read so far.
204 close();
205 setError(QAbstractSocket::RemoteHostClosedError, "Remote host closed"_L1);
207 return -1;
208 }
209 return bytesRead;
210}
211
213{
215 return d->socket->write(data, len);
216}
217
218#ifndef QT_NO_UDPSOCKET
219#ifndef QT_NO_NETWORKINTERFACE
221 const QNetworkInterface &)
222{
223 qWarning("Operation is not supported");
224 setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
225 return false;
226}
227
229 const QNetworkInterface &)
230{
231 qWarning("Operation is not supported");
232 setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
233 return false;
234}
235
237{
238 return QNetworkInterface();
239}
240
242{
243 qWarning("Operation is not supported");
244 setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
245 return false;
246}
247#endif // QT_NO_NETWORKINTERFACE
248
250{
251 qWarning("Operation is not supported");
252 return false;
253}
254
256{
257 qWarning("Operation is not supported");
258 return -1;
259}
260#endif // QT_NO_UDPSOCKET
261
263{
264 qWarning("Operation is not supported");
265 setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
266 return -1;
267}
268
270{
271 qWarning("Operation is not supported");
272 setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
273 return -1;
274}
275
277{
278 Q_D(const QHttpSocketEngine);
279 if (d->socket) {
280 return d->socket->bytesToWrite();
281 } else {
282 return 0;
283 }
284}
285
287{
288 Q_D(const QHttpSocketEngine);
289 if (d->socket) {
290 // convert the enum and call the real socket
292 return d->socket->socketOption(QAbstractSocket::LowDelayOption).toInt();
294 return d->socket->socketOption(QAbstractSocket::KeepAliveOption).toInt();
295 }
296 return -1;
297}
298
300{
302 if (d->socket) {
303 // convert the enum and call the real socket
305 d->socket->setSocketOption(QAbstractSocket::LowDelayOption, value);
307 d->socket->setSocketOption(QAbstractSocket::KeepAliveOption, value);
308 return true;
309 }
310 return false;
311}
312
313bool QHttpSocketEngine::waitForRead(int msecs, bool *timedOut)
314{
315 Q_D(const QHttpSocketEngine);
316
317 if (!d->socket || d->socket->state() == QAbstractSocket::UnconnectedState)
318 return false;
319
320 QElapsedTimer stopWatch;
321 stopWatch.start();
322
323 // Wait for more data if nothing is available.
324 if (!d->socket->bytesAvailable()) {
325 if (!d->socket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) {
326 if (d->socket->state() == QAbstractSocket::UnconnectedState)
327 return true;
328 setError(d->socket->error(), d->socket->errorString());
329 if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError)
330 *timedOut = true;
331 return false;
332 }
333 }
334
335 // If we're not connected yet, wait until we are, or until an error
336 // occurs.
337 while (d->state != Connected && d->socket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) {
338 // Loop while the protocol handshake is taking place.
339 }
340
341 // Report any error that may occur.
342 if (d->state != Connected) {
343 setError(d->socket->error(), d->socket->errorString());
344 if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError)
345 *timedOut = true;
346 return false;
347 }
348 return true;
349}
350
351bool QHttpSocketEngine::waitForWrite(int msecs, bool *timedOut)
352{
353 Q_D(const QHttpSocketEngine);
354
355 // If we're connected, just forward the call.
356 if (d->state == Connected) {
357 if (d->socket->bytesToWrite()) {
358 if (!d->socket->waitForBytesWritten(msecs)) {
359 if (d->socket->error() == QAbstractSocket::SocketTimeoutError && timedOut)
360 *timedOut = true;
361 return false;
362 }
363 }
364 return true;
365 }
366
367 QElapsedTimer stopWatch;
368 stopWatch.start();
369
370 // If we're not connected yet, wait until we are, and until bytes have
371 // been received (i.e., the socket has connected, we have sent the
372 // greeting, and then received the response).
373 while (d->state != Connected && d->socket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) {
374 // Loop while the protocol handshake is taking place.
375 }
376
377 // Report any error that may occur.
378 if (d->state != Connected) {
379// setError(d->socket->error(), d->socket->errorString());
380 if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError)
381 *timedOut = true;
382 }
383
384 return true;
385}
386
387bool QHttpSocketEngine::waitForReadOrWrite(bool *readyToRead, bool *readyToWrite,
388 bool checkRead, bool checkWrite,
389 int msecs, bool *timedOut)
390{
391 Q_UNUSED(checkRead);
392
393 if (!checkWrite) {
394 // Not interested in writing? Then we wait for read notifications.
395 bool canRead = waitForRead(msecs, timedOut);
396 if (readyToRead)
397 *readyToRead = canRead;
398 return canRead;
399 }
400
401 // Interested in writing? Then we wait for write notifications.
402 bool canWrite = waitForWrite(msecs, timedOut);
403 if (readyToWrite)
404 *readyToWrite = canWrite;
405 return canWrite;
406}
407
409{
410 Q_D(const QHttpSocketEngine);
411 return d->readNotificationEnabled;
412}
413
415{
417 if (d->readNotificationEnabled == enable)
418 return;
419
420 d->readNotificationEnabled = enable;
421 if (enable) {
422 // Enabling read notification can trigger a notification.
423 if (bytesAvailable()) {
425 } else if (d->socket && d->socket->state() == QAbstractSocket::UnconnectedState) {
426 emitReadNotification();
427 }
428 }
429}
430
432{
433 Q_D(const QHttpSocketEngine);
434 return d->writeNotificationEnabled;
435}
436
438{
440 d->writeNotificationEnabled = enable;
441 if (enable && d->state == Connected && d->socket->state() == QAbstractSocket::ConnectedState)
442 QMetaObject::invokeMethod(this, "writeNotification", Qt::QueuedConnection);
443}
444
446{
447 Q_D(const QHttpSocketEngine);
448 return d->exceptNotificationEnabled;
449}
450
452{
454 d->exceptNotificationEnabled = enable;
455}
456
458{
460
461 // Send the greeting.
462 const char method[] = "CONNECT";
463 QByteArray peerAddress = d->peerName.isEmpty() ?
464 d->peerAddress.toString().toLatin1() :
465 QUrl::toAce(d->peerName);
466 QByteArray path = peerAddress + ':' + QByteArray::number(d->peerPort);
468 data += ' ';
469 data += path;
470 data += " HTTP/1.1\r\n";
471 data += "Proxy-Connection: keep-alive\r\n";
472 data += "Host: " + peerAddress + "\r\n";
473 if (!d->proxy.hasRawHeader("User-Agent"))
474 data += "User-Agent: Mozilla/5.0\r\n";
475 const auto headers = d->proxy.rawHeaderList();
476 for (const QByteArray &header : headers)
477 data += header + ": " + d->proxy.rawHeader(header) + "\r\n";
479 //qDebug() << "slotSocketConnected: priv=" << priv << (priv ? (int)priv->method : -1);
480 if (priv && priv->method != QAuthenticatorPrivate::None) {
481 d->credentialsSent = true;
482 data += "Proxy-Authorization: " + priv->calculateResponse(method, path, d->proxy.hostName());
483 data += "\r\n";
484 }
485 data += "\r\n";
486// qDebug() << ">>>>>>>> sending request" << this;
487// qDebug() << data;
488// qDebug(">>>>>>>");
489 d->socket->write(data);
490 d->state = ConnectSent;
491}
492
494{
495}
496
498{
500 if (d->state != Connected && d->socket->bytesAvailable() == 0)
501 return;
502
503 if (d->state == Connected) {
504 // Forward as a read notification.
505 if (d->readNotificationEnabled)
506 emitReadNotification();
507 return;
508 }
509
510 if (d->state == ConnectSent) {
511 d->reply->d_func()->state = QHttpNetworkReplyPrivate::NothingDoneState;
512 d->state = ReadResponseHeader;
513 }
514
515 if (d->state == ReadResponseHeader) {
516 bool ok = readHttpHeader();
517 if (!ok) {
518 // protocol error, this isn't HTTP
519 d->socket->close();
521 setError(QAbstractSocket::ProxyProtocolError, tr("Did not receive HTTP response from proxy"));
522 emitConnectionNotification();
523 return;
524 }
525 if (d->state == ReadResponseHeader)
526 return; // readHttpHeader() was not done yet, need to wait for more header data
527 }
528
529 if (d->state == ReadResponseContent) {
530 qint64 skipped = d->socket->skip(d->pendingResponseData);
531 if (skipped == -1) {
532 d->socket->disconnectFromHost();
533 emitWriteNotification();
534 return;
535 }
536 d->pendingResponseData -= uint(skipped);
537 if (d->pendingResponseData > 0)
538 return;
539 if (d->reply->statusCode() == 407)
540 d->state = SendAuthentication;
541 }
542
543 int statusCode = d->reply->statusCode();
544 QAuthenticatorPrivate *priv = nullptr;
545 if (statusCode == 200) {
546 d->state = Connected;
547 setLocalAddress(d->socket->localAddress());
548 setLocalPort(d->socket->localPort());
549 d->inboundStreamCount = d->outboundStreamCount = 1;
551 d->authenticator.detach();
552 priv = QAuthenticatorPrivate::getPrivate(d->authenticator);
553 priv->hasFailed = false;
554 } else if (statusCode == 407) {
555 if (d->authenticator.isNull())
556 d->authenticator.detach();
557 priv = QAuthenticatorPrivate::getPrivate(d->authenticator);
558
559 if (d->credentialsSent && priv->phase != QAuthenticatorPrivate::Phase2) {
560 // Remember that (e.g.) NTLM is two-phase, so only reset when the authentication is not currently in progress.
561 //407 response again means the provided username/password were invalid.
562 d->authenticator = QAuthenticator(); //this is needed otherwise parseHttpResponse won't set the state, and then signal isn't emitted.
563 d->authenticator.detach();
564 priv = QAuthenticatorPrivate::getPrivate(d->authenticator);
565 priv->hasFailed = true;
566 }
567
568 priv->parseHttpResponse(d->reply->header(), true, d->proxy.hostName());
569
570 if (priv->phase == QAuthenticatorPrivate::Invalid) {
571 // problem parsing the reply
572 d->socket->close();
574 setError(QAbstractSocket::ProxyProtocolError, tr("Error parsing authentication request from proxy"));
575 emitConnectionNotification();
576 return;
577 }
578
579 bool willClose;
580 QByteArray proxyConnectionHeader = d->reply->headerField("Proxy-Connection");
581 // Although most proxies use the unofficial Proxy-Connection header, the Connection header
582 // from http spec is also allowed.
583 if (proxyConnectionHeader.isEmpty())
584 proxyConnectionHeader = d->reply->headerField("Connection");
585 if (proxyConnectionHeader.compare("close", Qt::CaseInsensitive) == 0) {
586 willClose = true;
587 } else if (proxyConnectionHeader.compare("keep-alive", Qt::CaseInsensitive) == 0) {
588 willClose = false;
589 } else {
590 // no Proxy-Connection header, so use the default
591 // HTTP 1.1's default behaviour is to keep persistent connections
592 // HTTP 1.0 or earlier, so we expect the server to close
593 willClose = (d->reply->majorVersion() * 0x100 + d->reply->minorVersion()) <= 0x0100;
594 }
595
596 if (willClose) {
597 // the server will disconnect, so let's avoid receiving an error
598 // especially since the signal below may trigger a new event loop
599 d->socket->disconnectFromHost();
600 d->socket->readAll();
601 //We're done with the reply and need to reset it for the next connection
602 delete d->reply;
603 d->reply = new QHttpNetworkReply(QUrl(), this);
604 }
605
606 if (priv->phase == QAuthenticatorPrivate::Done)
607 proxyAuthenticationRequired(d->proxy, &d->authenticator);
608 // priv->phase will get reset to QAuthenticatorPrivate::Start if the authenticator got modified in the signal above.
609 if (priv->phase == QAuthenticatorPrivate::Done) {
611 d->socket->disconnectFromHost();
612 } else {
613 // close the connection if it isn't already and reconnect using the chosen authentication method
614 d->state = SendAuthentication;
615 if (willClose) {
616 d->socket->connectToHost(d->proxy.hostName(), d->proxy.port());
617 } else {
618 // send the HTTP CONNECT again
620 }
621 return;
622 }
623 } else {
624 d->socket->close();
626 if (statusCode == 403 || statusCode == 405) {
627 // 403 Forbidden
628 // 405 Method Not Allowed
629 setError(QAbstractSocket::SocketAccessError, tr("Proxy denied connection"));
630 } else if (statusCode == 404) {
631 // 404 Not Found: host lookup error
632 setError(QAbstractSocket::HostNotFoundError, QAbstractSocket::tr("Host not found"));
633 } else if (statusCode == 503) {
634 // 503 Service Unavailable: Connection Refused
635 setError(QAbstractSocket::ConnectionRefusedError, QAbstractSocket::tr("Connection refused"));
636 } else {
637 // Some other reply
638 //qWarning("UNEXPECTED RESPONSE: [%s]", responseHeader.toString().toLatin1().data());
639 setError(QAbstractSocket::ProxyProtocolError, tr("Error communicating with HTTP proxy"));
640 }
641 }
642
643 // The handshake is done; notify that we're connected (or failed to connect)
644 emitConnectionNotification();
645}
646
647bool QHttpSocketEngine::readHttpHeader()
648{
650
651 if (d->state != ReadResponseHeader)
652 return false;
653
654 bool ok = true;
655 if (d->reply->d_func()->state == QHttpNetworkReplyPrivate::NothingDoneState) {
656 // do not keep old content sizes, status etc. around
657 d->reply->d_func()->clearHttpLayerInformation();
658 d->reply->d_func()->state = QHttpNetworkReplyPrivate::ReadingStatusState;
659 }
660 if (d->reply->d_func()->state == QHttpNetworkReplyPrivate::ReadingStatusState) {
661 ok = d->reply->d_func()->readStatus(d->socket) != -1;
662 if (ok && d->reply->d_func()->state == QHttpNetworkReplyPrivate::ReadingStatusState)
663 return true; //Not done parsing headers yet, wait for more data
664 }
665 if (ok && d->reply->d_func()->state == QHttpNetworkReplyPrivate::ReadingHeaderState) {
666 ok = d->reply->d_func()->readHeader(d->socket) != -1;
667 if (ok && d->reply->d_func()->state == QHttpNetworkReplyPrivate::ReadingHeaderState)
668 return true; //Not done parsing headers yet, wait for more data
669 }
670 if (ok) {
671 bool contentLengthOk;
672 int contentLength = d->reply->headerField("Content-Length").toInt(&contentLengthOk);
673 if (contentLengthOk && contentLength > 0)
674 d->pendingResponseData = contentLength;
675 d->state = ReadResponseContent; // we are done reading the header
676 }
677 return ok;
678}
679
681{
683 if (d->state == Connected && d->writeNotificationEnabled)
684 emitWriteNotification();
685}
686
688{
690
691 if (d->state != Connected) {
692 // we are in proxy handshaking stages
694 setError(QAbstractSocket::ProxyNotFoundError, tr("Proxy server not found"));
696 setError(QAbstractSocket::ProxyConnectionRefusedError, tr("Proxy connection refused"));
698 setError(QAbstractSocket::ProxyConnectionTimeoutError, tr("Proxy server connection timed out"));
700 setError(QAbstractSocket::ProxyConnectionClosedError, tr("Proxy connection closed prematurely"));
701 else
702 setError(error, d->socket->errorString());
703 emitConnectionNotification();
704 return;
705 }
706
707 // We're connected
709 return; // ignore this error
710
711 d->state = None;
712 setError(error, d->socket->errorString());
714 qDebug() << "QHttpSocketEngine::slotSocketError: got weird error =" << error;
715 //read notification needs to always be emitted, otherwise the higher layer doesn't get the disconnected signal
716 emitReadNotification();
717}
718
720{
722}
723
724void QHttpSocketEngine::emitPendingReadNotification()
725{
727 d->readNotificationPending = false;
728 if (d->readNotificationEnabled)
730}
731
732void QHttpSocketEngine::emitPendingWriteNotification()
733{
735 d->writeNotificationPending = false;
736 if (d->writeNotificationEnabled)
738}
739
740void QHttpSocketEngine::emitPendingConnectionNotification()
741{
743 d->connectionNotificationPending = false;
745}
746
747void QHttpSocketEngine::emitReadNotification()
748{
750 // if there is a connection notification pending we have to emit the readNotification
751 // in case there is connection error. This is only needed for Windows, but it does not
752 // hurt in other cases.
753 if ((d->readNotificationEnabled && !d->readNotificationPending) || d->connectionNotificationPending) {
754 d->readNotificationPending = true;
755 QMetaObject::invokeMethod(this, "emitPendingReadNotification", Qt::QueuedConnection);
756 }
757}
758
759void QHttpSocketEngine::emitWriteNotification()
760{
762 if (d->writeNotificationEnabled && !d->writeNotificationPending) {
763 d->writeNotificationPending = true;
764 QMetaObject::invokeMethod(this, "emitPendingWriteNotification", Qt::QueuedConnection);
765 }
766}
767
768void QHttpSocketEngine::emitConnectionNotification()
769{
771 if (!d->connectionNotificationPending) {
772 d->connectionNotificationPending = true;
773 QMetaObject::invokeMethod(this, "emitPendingConnectionNotification", Qt::QueuedConnection);
774 }
775}
776
778 : readNotificationEnabled(false)
779 , writeNotificationEnabled(false)
780 , exceptNotificationEnabled(false)
781 , readNotificationPending(false)
782 , writeNotificationPending(false)
783 , connectionNotificationPending(false)
784 , credentialsSent(false)
785 , pendingResponseData(0)
786{
787 socket = nullptr;
788 reply = nullptr;
790}
791
793{
794}
795
797 const QNetworkProxy &proxy,
799{
801 return nullptr;
802
803 // proxy type must have been resolved by now
805 return nullptr;
806
807 // we only accept active sockets
808 if (!qobject_cast<QAbstractSocket *>(parent))
809 return nullptr;
810
812 engine->setProxy(proxy);
813 return engine;
814}
815
817{
818 return nullptr;
819}
820
822
823#endif // !QT_NO_NETWORKPROXY
824
825#include "moc_qhttpsocketengine_p.cpp"
bool connected
QAbstractSocket::SocketError error() const
QAbstractSocket::NetworkLayerProtocol protocol() const
void setPeerAddress(const QHostAddress &address)
void setState(QAbstractSocket::SocketState state)
void setLocalAddress(const QHostAddress &address)
void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator)
QAbstractSocket::SocketState state() const
void setSocketType(QAbstractSocket::SocketType socketType)
QHostAddress peerAddress() const
void setError(QAbstractSocket::SocketError error, const QString &errorString) const
void setProtocol(QAbstractSocket::NetworkLayerProtocol protocol)
SocketState
This enum describes the different states in which a socket can be.
SocketError
This enum describes the socket errors that can occur.
SocketType
This enum describes the transport layer protocol.
static QAuthenticatorPrivate * getPrivate(QAuthenticator &auth)
The QAuthenticator class provides an authentication object.
\inmodule QtCore
Definition qbytearray.h:57
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
Definition qbytearray.h:106
static QByteArray number(int, int base=10)
Returns a byte-array representing the whole number n as text.
int compare(QByteArrayView a, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
Definition qbytearray.h:587
\inmodule QtCore
qint64 elapsed() const noexcept
Returns the number of milliseconds since this QElapsedTimer was last started.
void start() noexcept
Starts this timer.
The QHostAddress class provides an IP address.
virtual QAbstractSocketEngine * createSocketEngine(QAbstractSocket::SocketType socketType, const QNetworkProxy &, QObject *parent) override
QHttpSocketEngine::HttpState state
void setWriteNotificationEnabled(bool enable) override
bool joinMulticastGroup(const QHostAddress &groupAddress, const QNetworkInterface &interface) override
bool bind(const QHostAddress &address, quint16 port) override
void slotSocketStateChanged(QAbstractSocket::SocketState state)
bool isWriteNotificationEnabled() const override
bool leaveMulticastGroup(const QHostAddress &groupAddress, const QNetworkInterface &interface) override
bool setMulticastInterface(const QNetworkInterface &iface) override
qint64 readDatagram(char *data, qint64 maxlen, QIpPacketHeader *, PacketHeaderOptions) override
bool listen(int backlog) override
QHttpSocketEngine(QObject *parent=nullptr)
bool isValid() const override
qint64 write(const char *data, qint64 len) override
bool waitForWrite(int msecs=30000, bool *timedOut=nullptr) override
bool connectToHostByName(const QString &name, quint16 port) override
qintptr socketDescriptor() const override
void setExceptionNotificationEnabled(bool enable) override
bool hasPendingDatagrams() const override
qint64 bytesToWrite() const override
bool isReadNotificationEnabled() const override
QNetworkInterface multicastInterface() const override
bool setOption(SocketOption option, int value) override
qint64 bytesAvailable() const override
bool connectToHost(const QHostAddress &address, quint16 port) override
qint64 read(char *data, qint64 maxlen) override
int option(SocketOption option) const override
void setReadNotificationEnabled(bool enable) override
qintptr accept() override
void setProxy(const QNetworkProxy &networkProxy)
bool isExceptionNotificationEnabled() const override
bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol=QAbstractSocket::IPv4Protocol) override
bool waitForReadOrWrite(bool *readyToRead, bool *readyToWrite, bool checkRead, bool checkWrite, int msecs=30000, bool *timedOut=nullptr) override
void slotSocketError(QAbstractSocket::SocketError error)
bool waitForRead(int msecs=30000, bool *timedOut=nullptr) override
qint64 writeDatagram(const char *data, qint64 len, const QIpPacketHeader &) override
qint64 pendingDatagramSize() const override
The QNetworkInterface class provides a listing of the host's IP addresses and network interfaces.
The QNetworkProxy class provides a network layer proxy.
QString user() const
Returns the user name used for authentication.
QNetworkProxy::ProxyType type() const
Returns the proxy type for this instance.
QString password() const
Returns the password used for authentication.
\inmodule QtCore
Definition qobject.h:90
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2823
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:1083
The QTcpSocket class provides a TCP socket.
Definition qtcpsocket.h:18
\inmodule QtCore
Definition qurl.h:94
static QByteArray toAce(const QString &domain, AceProcessingOptions options={})
Definition qurl.cpp:3061
else opt state
[0]
Combined button and popup list for selecting options.
@ CaseInsensitive
@ QueuedConnection
@ DirectConnection
DBusConnection const char DBusError * error
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char * method
static QString header(const QString &name)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
EGLOutputPortEXT port
static QT_BEGIN_NAMESPACE const char * socketType(QSocketNotifier::Type type)
int qt_subtract_from_timeout(int timeout, int elapsed)
#define qDebug
[1]
Definition qlogging.h:160
#define qWarning
Definition qlogging.h:162
static const QMetaObjectPrivate * priv(const uint *data)
#define SLOT(a)
Definition qobjectdefs.h:51
#define SIGNAL(a)
Definition qobjectdefs.h:52
GLenum GLsizei GLuint GLint * bytesWritten
GLenum type
GLboolean enable
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLsizei len
GLuint GLuint64EXT address
GLsizei const GLchar *const * path
GLuint GLenum option
#define tr(X)
#define Q_UNUSED(x)
unsigned short quint16
Definition qtypes.h:43
unsigned int uint
Definition qtypes.h:29
long long qint64
Definition qtypes.h:55
ptrdiff_t qintptr
Definition qtypes.h:71
QNetworkProxy proxy
[0]
socketLayer waitForWrite()
QJSEngine engine
[0]
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(nullptr), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
\threadsafe This is an overloaded member function, provided for convenience. It differs from the abov...
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent