QtBase  v6.3.1
qabstractsocket.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2022 The Qt Company Ltd.
4 ** Copyright (C) 2016 Intel Corporation.
5 ** Contact: https://www.qt.io/licensing/
6 **
7 ** This file is part of the QtNetwork module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** Commercial License Usage
11 ** Licensees holding valid commercial Qt licenses may use this file in
12 ** accordance with the commercial license agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and The Qt Company. For licensing terms
15 ** and conditions see https://www.qt.io/terms-conditions. For further
16 ** information use the contact form at https://www.qt.io/contact-us.
17 **
18 ** GNU Lesser General Public License Usage
19 ** Alternatively, this file may be used under the terms of the GNU Lesser
20 ** General Public License version 3 as published by the Free Software
21 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
22 ** packaging of this file. Please review the following information to
23 ** ensure the GNU Lesser General Public License version 3 requirements
24 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25 **
26 ** GNU General Public License Usage
27 ** Alternatively, this file may be used under the terms of the GNU
28 ** General Public License version 2.0 or (at your option) the GNU General
29 ** Public license version 3 or any later version approved by the KDE Free
30 ** Qt Foundation. The licenses are as published by the Free Software
31 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32 ** included in the packaging of this file. Please review the following
33 ** information to ensure the GNU General Public License requirements will
34 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
35 ** https://www.gnu.org/licenses/gpl-3.0.html.
36 **
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40 
41 //#define QABSTRACTSOCKET_DEBUG
42 
465 #include <QtNetwork/private/qtnetworkglobal_p.h>
466 
467 #include "qabstractsocket.h"
468 #include "qabstractsocket_p.h"
469 
470 #include "private/qhostinfo_p.h"
471 
473 #include <qhostaddress.h>
474 #include <qhostinfo.h>
475 #include <qmetaobject.h>
476 #include <qpointer.h>
477 #include <qtimer.h>
478 #include <qelapsedtimer.h>
479 #include <qscopedvaluerollback.h>
480 #include <qvarlengtharray.h>
481 
482 #include <private/qthread_p.h>
483 
484 #ifdef QABSTRACTSOCKET_DEBUG
485 #include <qdebug.h>
486 #include <private/qdebug_p.h>
487 #endif
488 
489 #include <time.h>
490 
491 #define Q_CHECK_SOCKETENGINE(returnValue) do { \
492  if (!d->socketEngine) { \
493  return returnValue; \
494  } } while (0)
495 
496 #ifndef QABSTRACTSOCKET_BUFFERSIZE
497 #define QABSTRACTSOCKET_BUFFERSIZE 32768
498 #endif
499 #define QT_TRANSFER_TIMEOUT 120000
500 
502 
503 static const int DefaultConnectTimeout = 30000;
504 
505 static bool isProxyError(QAbstractSocket::SocketError error)
506 {
507  switch (error) {
514  return true;
515  default:
516  return false;
517  }
518 }
519 
525  : emittedReadyRead(false),
526  emittedBytesWritten(false),
527  abortCalled(false),
528  pendingClose(false),
529  pauseMode(QAbstractSocket::PauseNever),
530  port(0),
531  localPort(0),
532  peerPort(0),
533  socketEngine(nullptr),
534  cachedSocketDescriptor(-1),
535  readBufferMaxSize(0),
536  isBuffered(false),
537  hasPendingData(false),
538  connectTimer(nullptr),
539  hostLookupId(-1),
540  socketType(QAbstractSocket::UnknownSocketType),
541  state(QAbstractSocket::UnconnectedState),
542  socketError(QAbstractSocket::UnknownSocketError),
543  preferredNetworkLayerProtocol(QAbstractSocket::UnknownNetworkLayerProtocol)
544 {
546 }
547 
554 {
555 }
556 
562 {
563 #if defined (QABSTRACTSOCKET_DEBUG)
564  qDebug("QAbstractSocketPrivate::resetSocketLayer()");
565 #endif
566 
567  hasPendingData = false;
568  if (socketEngine) {
569  socketEngine->close();
571  delete socketEngine;
572  socketEngine = nullptr;
574  }
575  if (connectTimer)
576  connectTimer->stop();
577 }
578 
586 {
587 #ifdef QT_NO_NETWORKPROXY
588  // this is here to avoid a duplication of the call to createSocketEngine below
589  static const QNetworkProxy &proxyInUse = *(QNetworkProxy *)0;
590 #endif
591 
592  Q_Q(QAbstractSocket);
593 #if defined (QABSTRACTSOCKET_DEBUG)
594  QString typeStr;
595  if (q->socketType() == QAbstractSocket::TcpSocket) typeStr = QLatin1String("TcpSocket");
596  else if (q->socketType() == QAbstractSocket::UdpSocket) typeStr = QLatin1String("UdpSocket");
597  else if (q->socketType() == QAbstractSocket::SctpSocket) typeStr = QLatin1String("SctpSocket");
598  else typeStr = QLatin1String("UnknownSocketType");
599  QString protocolStr;
600  if (protocol == QAbstractSocket::IPv4Protocol) protocolStr = QLatin1String("IPv4Protocol");
601  else if (protocol == QAbstractSocket::IPv6Protocol) protocolStr = QLatin1String("IPv6Protocol");
602  else protocolStr = QLatin1String("UnknownNetworkLayerProtocol");
603 #endif
604 
607  if (!socketEngine) {
609  QAbstractSocket::tr("Operation on socket is not supported"));
610  return false;
611  }
612  if (!socketEngine->initialize(q->socketType(), protocol)) {
613 #if defined (QABSTRACTSOCKET_DEBUG)
614  qDebug("QAbstractSocketPrivate::initSocketLayer(%s, %s) failed (%s)",
615  typeStr.toLatin1().constData(), protocolStr.toLatin1().constData(),
617 #endif
619  return false;
620  }
621 
623 
624  if (threadData.loadRelaxed()->hasEventDispatcher())
625  socketEngine->setReceiver(this);
626 
627 #if defined (QABSTRACTSOCKET_DEBUG)
628  qDebug("QAbstractSocketPrivate::initSocketLayer(%s, %s) success",
629  typeStr.toLatin1().constData(), protocolStr.toLatin1().constData());
630 #endif
631  return true;
632 }
633 
637 {
638 #ifndef QT_NO_SCTP
639  Q_Q(QAbstractSocket);
640  // Set single stream mode for unbuffered SCTP socket
643 #endif
644 }
645 
653 {
654  Q_Q(QAbstractSocket);
655 #if defined (QABSTRACTSOCKET_DEBUG)
656  qDebug("QAbstractSocketPrivate::canReadNotification()");
657 #endif
658 
659  // If buffered, read data from the socket into the read buffer
660  if (isBuffered) {
661  const qint64 oldBufferSize = buffer.size();
662 
663  // Return if there is no space in the buffer
664  if (readBufferMaxSize && oldBufferSize >= readBufferMaxSize) {
666 #if defined (QABSTRACTSOCKET_DEBUG)
667  qDebug("QAbstractSocketPrivate::canReadNotification() buffer is full");
668 #endif
669  return false;
670  }
671 
672  // If reading from the socket fails after getting a read
673  // notification, close the socket.
674  if (!readFromSocket()) {
675 #if defined (QABSTRACTSOCKET_DEBUG)
676  qDebug("QAbstractSocketPrivate::canReadNotification() disconnecting socket");
677 #endif
678  q->disconnectFromHost();
679  return false;
680  }
681 
682  // Return if there is no new data available.
683  if (buffer.size() == oldBufferSize) {
684  // If the socket is opened only for writing, return true
685  // to indicate that the data was discarded.
686  return !q->isReadable();
687  }
688  } else {
689  if (hasPendingData) {
691  return true;
692  }
693  hasPendingData = true;
694  }
695 
696  emitReadyRead();
697 
698 #if defined (QABSTRACTSOCKET_DEBUG)
699  // If we were closed as a result of the readyRead() signal.
701  qDebug("QAbstractSocketPrivate::canReadNotification() socket is closing - returning");
702 #endif
703 
704  return true;
705 }
706 
713 {
714  Q_Q(QAbstractSocket);
715  // Note that this method is only called on Windows. Other platforms close in the canReadNotification()
716 
717 #if defined (QABSTRACTSOCKET_DEBUG)
718  qDebug("QAbstractSocketPrivate::canCloseNotification()");
719 #endif
720 
721  qint64 newBytes = 0;
722  if (isBuffered) {
723  // Try to read to the buffer, if the read fail we can close the socket.
724  newBytes = buffer.size();
725  qint64 oldReadBufferMaxSize = readBufferMaxSize;
726  readBufferMaxSize = 0; // temporarily disable max read buffer, we want to empty the OS buffer
727  bool hadReadFromSocket = readFromSocket();
728  readBufferMaxSize = oldReadBufferMaxSize;
729  if (!hadReadFromSocket) {
730  q->disconnectFromHost();
731  return;
732  }
733  newBytes = buffer.size() - newBytes;
734  if (newBytes) {
735  // If there was still some data to be read from the socket
736  // then we could get another FD_READ. The disconnect will
737  // then occur when we read from the socket again and fail
738  // in canReadNotification or by the manually created
739  // closeNotification below.
740  emitReadyRead();
741 
743  }
744  } else if ((socketType == QAbstractSocket::TcpSocket ||
746  emitReadyRead();
747  }
748 }
749 
750 
757 {
758 #if defined (QABSTRACTSOCKET_DEBUG)
759  qDebug("QAbstractSocketPrivate::canWriteNotification() flushing");
760 #endif
761 
762  return writeToSocket();
763 }
764 
771 {
772  // If in connecting state, check if the connection has been
773  // established, otherwise flush pending data.
775 #if defined (QABSTRACTSOCKET_DEBUG)
776  qDebug("QAbstractSocketPrivate::connectionNotification() testing connection");
777 #endif
779  }
780 }
781 
792 {
793  Q_Q(QAbstractSocket);
794  if (!socketEngine || !socketEngine->isValid() || (writeBuffer.isEmpty()
795  && socketEngine->bytesToWrite() == 0)) {
796 #if defined (QABSTRACTSOCKET_DEBUG)
797  qDebug("QAbstractSocketPrivate::writeToSocket() nothing to do: valid ? %s, writeBuffer.isEmpty() ? %s",
798  (socketEngine && socketEngine->isValid()) ? "yes" : "no", writeBuffer.isEmpty() ? "yes" : "no");
799 #endif
800 
801  // this covers the case when the buffer was empty, but we had to wait for the socket engine to finish
803  q->disconnectFromHost();
804  } else {
805  if (socketEngine)
807  }
808 
809  return false;
810  }
811 
812  qint64 nextSize = writeBuffer.nextDataBlockSize();
813  const char *ptr = writeBuffer.readPointer();
814 
815  // Attempt to write it all in one chunk.
816  qint64 written = nextSize ? socketEngine->write(ptr, nextSize) : Q_INT64_C(0);
817  if (written < 0) {
818 #if defined (QABSTRACTSOCKET_DEBUG)
819  qDebug() << "QAbstractSocketPrivate::writeToSocket() write error, aborting."
821 #endif
823  // an unexpected error so close the socket.
824  q->abort();
825  return false;
826  }
827 
828 #if defined (QABSTRACTSOCKET_DEBUG)
829  qDebug("QAbstractSocketPrivate::writeToSocket() %lld bytes written to the network",
830  written);
831 #endif
832 
833  if (written > 0) {
834  // Remove what we wrote so far.
835  writeBuffer.free(written);
836 
837  // Emit notifications.
838  emitBytesWritten(written);
839  }
840 
841  if (writeBuffer.isEmpty() && socketEngine && !socketEngine->bytesToWrite())
844  q->disconnectFromHost();
845 
846  return written > 0;
847 }
848 
856 {
857  bool dataWasWritten = false;
858 
859  while (!allWriteBuffersEmpty() && writeToSocket())
860  dataWasWritten = true;
861 
862  return dataWasWritten;
863 }
864 
865 #ifndef QT_NO_NETWORKPROXY
871 {
872  QList<QNetworkProxy> proxies;
873 
875  // a non-default proxy was set with setProxy
876  proxies << proxy;
877  } else {
878  // try the application settings instead
886  }
887 
888  // return the first that we can use
889  for (const QNetworkProxy &p : qAsConst(proxies)) {
891  (p.capabilities() & QNetworkProxy::UdpTunnelingCapability) == 0)
892  continue;
893 
895  (p.capabilities() & QNetworkProxy::TunnelingCapability) == 0)
896  continue;
897 
899  (p.capabilities() & QNetworkProxy::SctpTunnelingCapability) == 0)
900  continue;
901 
902  proxyInUse = p;
903  return;
904  }
905 
906  // no proxy found
907  // DefaultProxy here will raise an error
909 }
910 #endif // !QT_NO_NETWORKPROXY
911 
912 #if !defined(QT_NO_NETWORKPROXY)
920 {
921  Q_Q(QAbstractSocket);
923  return;
924 
925 #if defined(QABSTRACTSOCKET_DEBUG)
926  qDebug("QAbstractSocketPrivate::startConnectingByName(host == %s)", qPrintable(host));
927 #endif
928 
929  // ### Let the socket engine drive this?
931  emit q->stateChanged(state);
932 
934  // Try to connect to the host. If it succeeds immediately
935  // (e.g. QSocks5SocketEngine in UDPASSOCIATE mode), emit
936  // connected() and return.
939  return;
940  }
941 
943  return;
944 
945  // failed to connect
947  }
948 
950  emit q->errorOccurred(socketError);
951  emit q->stateChanged(state);
952 }
953 
954 #endif // !QT_NO_NETWORKPROXY
955 
964 {
965  Q_Q(QAbstractSocket);
966  addresses.clear();
968  return;
969 
970  if (hostLookupId != -1 && hostLookupId != hostInfo.lookupId()) {
971  qWarning("QAbstractSocketPrivate::_q_startConnecting() received hostInfo for wrong lookup ID %d expected %d", hostInfo.lookupId(), hostLookupId);
972  }
973 
974  // Only add the addresses for the preferred network layer.
975  // Or all if preferred network layer is not set.
977  addresses = hostInfo.addresses();
978  } else {
979  const auto candidates = hostInfo.addresses();
980  for (const QHostAddress &address : candidates) {
981  if (address.protocol() == preferredNetworkLayerProtocol)
982  addresses += address;
983  }
984  }
985 
986 
987 #if defined(QABSTRACTSOCKET_DEBUG)
988  QString s = QLatin1String("{");
989  for (int i = 0; i < addresses.count(); ++i) {
990  if (i != 0) s += QLatin1String(", ");
991  s += addresses.at(i).toString();
992  }
993  s += QLatin1Char('}');
994  qDebug("QAbstractSocketPrivate::_q_startConnecting(hostInfo == %s)", s.toLatin1().constData());
995 #endif
996 
997  // Try all addresses twice.
998  addresses += addresses;
999 
1000  // If there are no addresses in the host list, report this to the
1001  // user.
1002  if (addresses.isEmpty()) {
1003 #if defined(QABSTRACTSOCKET_DEBUG)
1004  qDebug("QAbstractSocketPrivate::_q_startConnecting(), host not found");
1005 #endif
1008  emit q->stateChanged(state);
1009  emit q->errorOccurred(QAbstractSocket::HostNotFoundError);
1010  return;
1011  }
1012 
1013  // Enter Connecting state (see also sn_write, which is called by
1014  // the write socket notifier after connect())
1016  emit q->stateChanged(state);
1017 
1018  // Report the successful host lookup
1019  emit q->hostFound();
1020 
1021  // The addresses returned by the lookup will be tested one after
1022  // another by _q_connectToNextAddress().
1024 }
1025 
1036 {
1037  Q_Q(QAbstractSocket);
1038  do {
1039  // Check for more pending addresses
1040  if (addresses.isEmpty()) {
1041 #if defined(QABSTRACTSOCKET_DEBUG)
1042  qDebug("QAbstractSocketPrivate::_q_connectToNextAddress(), all addresses failed.");
1043 #endif
1045  if (socketEngine) {
1047 #ifdef Q_OS_AIX
1048  // On AIX, the second connect call will result in EINVAL and not
1049  // ECONNECTIONREFUSED; although the meaning is the same.
1051 #endif
1054  QAbstractSocket::tr("Connection refused"));
1055  } else {
1057  }
1058  } else {
1059 // socketError = QAbstractSocket::ConnectionRefusedError;
1060 // q->setErrorString(QAbstractSocket::tr("Connection refused"));
1061  }
1062  emit q->stateChanged(state);
1063  emit q->errorOccurred(socketError);
1064  return;
1065  }
1066 
1067  // Pick the first host address candidate
1068  host = addresses.takeFirst();
1069 #if defined(QABSTRACTSOCKET_DEBUG)
1070  qDebug("QAbstractSocketPrivate::_q_connectToNextAddress(), connecting to %s:%i, %d left to try",
1072 #endif
1073 
1075  // hope that the next address is better
1076 #if defined(QABSTRACTSOCKET_DEBUG)
1077  qDebug("QAbstractSocketPrivate::_q_connectToNextAddress(), failed to initialize sock layer");
1078 #endif
1079  continue;
1080  }
1081 
1082  // Tries to connect to the address. If it succeeds immediately
1083  // (localhost address on BSD or any UDP connect), emit
1084  // connected() and return.
1085  if (
1087  //_q_testConnection();
1089  return;
1090  }
1091 
1092  // Check that we're in delayed connection state. If not, try
1093  // the next address
1095 #if defined(QABSTRACTSOCKET_DEBUG)
1096  qDebug("QAbstractSocketPrivate::_q_connectToNextAddress(), connection failed (%s)",
1098 #endif
1099  continue;
1100  }
1101 
1102  // Start the connect timer.
1103  if (threadData.loadRelaxed()->hasEventDispatcher()) {
1104  if (!connectTimer) {
1105  connectTimer = new QTimer(q);
1109  }
1110  int connectTimeout = DefaultConnectTimeout;
1111  connectTimer->start(connectTimeout);
1112  }
1113 
1114  // Wait for a write notification that will eventually call
1115  // _q_testConnection().
1117  break;
1119 }
1120 
1127 {
1128  if (connectTimer)
1129  connectTimer->stop();
1130 
1131  if (socketEngine) {
1133  // Fetch the parameters if our connection is completed;
1134  // otherwise, fall out and try the next address.
1136  if (pendingClose) {
1137  q_func()->disconnectFromHost();
1138  pendingClose = false;
1139  }
1140  return;
1141  }
1142 
1143  // don't retry the other addresses if we had a proxy error
1144  if (isProxyError(socketEngine->error()))
1145  addresses.clear();
1146  }
1147 
1148 #if defined(QABSTRACTSOCKET_DEBUG)
1149  qDebug("QAbstractSocketPrivate::_q_testConnection() connection failed,"
1150  " checking for alternative addresses");
1151 #endif
1153 }
1154 
1163 {
1164  Q_Q(QAbstractSocket);
1165 #if defined(QABSTRACTSOCKET_DEBUG)
1166  qDebug("QAbstractSocketPrivate::_q_abortConnectionAttempt() (timed out)");
1167 #endif
1168  if (socketEngine)
1170 
1171  connectTimer->stop();
1172 
1173  if (addresses.isEmpty()) {
1176  QAbstractSocket::tr("Connection timed out"));
1177  emit q->stateChanged(state);
1178  emit q->errorOccurred(socketError);
1179  } else {
1181  }
1182 }
1183 
1190 {
1191  Q_Q(QAbstractSocket);
1192  // Find how many bytes we can read from the socket layer.
1193  qint64 bytesToRead = socketEngine->bytesAvailable();
1194  if (bytesToRead == 0) {
1195  // Under heavy load, certain conditions can trigger read notifications
1196  // for socket notifiers on which there is no activity. If we continue
1197  // to read 0 bytes from the socket, we will trigger behavior similar
1198  // to that which signals a remote close. When we hit this condition,
1199  // we try to read 4k of data from the socket, which will give us either
1200  // an EAGAIN/EWOULDBLOCK if the connection is alive (i.e., the remote
1201  // host has _not_ disappeared).
1202  bytesToRead = 4096;
1203  }
1204 
1205  if (q->isReadable()) {
1206  if (readBufferMaxSize && bytesToRead > (readBufferMaxSize - buffer.size()))
1207  bytesToRead = readBufferMaxSize - buffer.size();
1208 
1209 #if defined(QABSTRACTSOCKET_DEBUG)
1210  qDebug("QAbstractSocketPrivate::readFromSocket() about to read %lld bytes",
1211  bytesToRead);
1212 #endif
1213 
1214  // Read from the socket, store data in the read buffer.
1215  char *ptr = buffer.reserve(bytesToRead);
1216  qint64 readBytes = socketEngine->read(ptr, bytesToRead);
1217  if (readBytes == -2) {
1218  // No bytes currently available for reading.
1219  buffer.chop(bytesToRead);
1220  return true;
1221  }
1222  buffer.chop(bytesToRead - (readBytes < 0 ? qint64(0) : readBytes));
1223 #if defined(QABSTRACTSOCKET_DEBUG)
1224  qDebug("QAbstractSocketPrivate::readFromSocket() got %lld bytes, buffer size = %lld",
1225  readBytes, buffer.size());
1226 #endif
1227  } else {
1228  // Discard unwanted data if opened in WriteOnly mode
1229  QVarLengthArray<char, 4096> discardBuffer(bytesToRead);
1230 
1231 #if defined(QABSTRACTSOCKET_DEBUG)
1232  qDebug("QAbstractSocketPrivate::readFromSocket() about to discard %lld bytes",
1233  bytesToRead);
1234 #endif
1235  socketEngine->read(discardBuffer.data(), bytesToRead);
1236  }
1237 
1238  if (!socketEngine->isValid()) {
1239 #if defined(QABSTRACTSOCKET_DEBUG)
1240  qDebug("QAbstractSocketPrivate::readFromSocket() read failed: %s",
1242 #endif
1244  resetSocketLayer();
1245  return false;
1246  }
1247 
1248  return true;
1249 }
1250 
1256 {
1257  Q_Q(QAbstractSocket);
1258  // Only emit readyRead() when not recursing.
1259  if (!emittedReadyRead && channel == currentReadChannel) {
1261  emittedReadyRead = true;
1262  emit q->readyRead();
1263  }
1264  // channelReadyRead() can be emitted recursively - even for the same channel.
1265  emit q->channelReadyRead(channel);
1266 }
1267 
1273 {
1274  Q_Q(QAbstractSocket);
1275  // Only emit bytesWritten() when not recursing.
1276  if (!emittedBytesWritten && channel == currentWriteChannel) {
1278  emittedBytesWritten = true;
1279  emit q->bytesWritten(bytes);
1280  }
1281  // channelBytesWritten() can be emitted recursively - even for the same channel.
1282  emit q->channelBytesWritten(channel, bytes);
1283 }
1284 
1290 {
1291  Q_Q(QAbstractSocket);
1292 
1293  peerName = hostName;
1294  if (socketEngine) {
1295  if (q->isReadable()) {
1296  const int inboundStreamCount = socketEngine->inboundStreamCount();
1297  setReadChannelCount(qMax(1, inboundStreamCount));
1298  if (inboundStreamCount == 0)
1299  readChannelCount = 0;
1300  }
1301  if (q->isWritable()) {
1302  const int outboundStreamCount = socketEngine->outboundStreamCount();
1303  setWriteChannelCount(qMax(1, outboundStreamCount));
1304  if (outboundStreamCount == 0)
1305  writeChannelCount = 0;
1306  }
1314  }
1315 
1317 #if defined(QABSTRACTSOCKET_DEBUG)
1318  qDebug("QAbstractSocketPrivate::fetchConnectionParameters() connection to %s:%i established",
1320 #endif
1321  emit q->stateChanged(state);
1322  emit q->connected();
1323 }
1324 
1328 {
1329  Q_D(const QAbstractSocket);
1330 
1331  // if we're not connected, return -1 indicating EOF
1332  if (!d->socketEngine || !d->socketEngine->isValid()
1333  || d->state != QAbstractSocket::ConnectedState)
1334  return -1;
1335 
1336  // Caller, QIODevice::skip(), has ensured buffer is empty. So, wait
1337  // for more data in buffered mode.
1338  if (d->isBuffered)
1339  return 0;
1340 
1341  return QIODevice::skipData(maxSize);
1342 }
1343 
1345 {
1346  QAbstractSocketEngine *socketEngine = socket->d_func()->socketEngine;
1347  if (!socketEngine)
1348  return;
1352 
1353 #ifdef QABSTRACTSOCKET_DEBUG
1355  << "pause notifiers, storing 'true' states, currently read:" << read
1356  << "write:" << write << "except:" << except;
1357 #endif
1358  // We do this if-check to avoid accidentally overwriting any previously stored state
1359  // It will reset to false once the socket is re-enabled.
1360  if (read) {
1361  socket->d_func()->prePauseReadSocketNotifierState = true;
1363  }
1364  if (write) {
1365  socket->d_func()->prePauseWriteSocketNotifierState = true;
1367  }
1368  if (except) {
1369  socket->d_func()->prePauseExceptionSocketNotifierState = true;
1371  }
1372 }
1373 
1375 {
1376  QAbstractSocketEngine *socketEngine = socket->d_func()->socketEngine;
1377  if (!socketEngine)
1378  return;
1379  QAbstractSocketPrivate *priv = socket->d_func();
1380 #ifdef QABSTRACTSOCKET_DEBUG
1382  << "Maybe resume notifiers, read:" << priv->prePauseReadSocketNotifierState
1383  << "write:" << priv->prePauseWriteSocketNotifierState
1384  << "exception:" << priv->prePauseExceptionSocketNotifierState;
1385 #endif
1386  if (std::exchange(priv->prePauseReadSocketNotifierState, false))
1388  if (std::exchange(priv->prePauseWriteSocketNotifierState, false))
1390  if (std::exchange(priv->prePauseExceptionSocketNotifierState, false))
1392 }
1393 
1395 {
1396  return socket->d_func()->socketEngine;
1397 }
1398 
1405  const QString &errStr)
1406 {
1407  socketError = errorCode;
1408  errorString = errStr;
1409 }
1410 
1418  const QString &errorString)
1419 {
1420  Q_Q(QAbstractSocket);
1421  setError(errorCode, errorString);
1422  emit q->errorOccurred(errorCode);
1423 }
1424 
1432  : QIODevice(dd, parent)
1433 {
1434  Q_D(QAbstractSocket);
1435 #if defined(QABSTRACTSOCKET_DEBUG)
1436  qDebug("QAbstractSocket::QAbstractSocket(%sSocket, QAbstractSocketPrivate == %p, parent == %p)",
1437  socketType == TcpSocket ? "Tcp" : socketType == UdpSocket ? "Udp"
1438  : socketType == SctpSocket ? "Sctp" : "Unknown", &dd, parent);
1439 #endif
1440  d->socketType = socketType;
1441 }
1442 
1450  : QAbstractSocket(socketType, *new QAbstractSocketPrivate, parent)
1451 {
1452 }
1453 
1458 {
1459  Q_D(QAbstractSocket);
1460 #if defined(QABSTRACTSOCKET_DEBUG)
1461  qDebug("QAbstractSocket::~QAbstractSocket()");
1462 #endif
1463  if (d->state != UnconnectedState)
1464  abort();
1465 }
1466 
1480 {
1482 }
1483 
1491 QAbstractSocket::PauseModes QAbstractSocket::pauseMode() const
1492 {
1493  return d_func()->pauseMode;
1494 }
1495 
1496 
1511 void QAbstractSocket::setPauseMode(PauseModes pauseMode)
1512 {
1513  d_func()->pauseMode = pauseMode;
1514 }
1515 
1537 {
1538  Q_D(QAbstractSocket);
1539  return d->bind(address, port, mode);
1540 }
1541 
1542 bool QAbstractSocketPrivate::bind(const QHostAddress &address, quint16 port, QAbstractSocket::BindMode mode)
1543 {
1544  Q_Q(QAbstractSocket);
1545 
1546  // now check if the socket engine is initialized and to the right type
1547  if (!socketEngine || !socketEngine->isValid()) {
1548  QHostAddress nullAddress;
1549  resolveProxy(nullAddress.toString(), port);
1550 
1551  QAbstractSocket::NetworkLayerProtocol protocol = address.protocol();
1553  protocol = nullAddress.protocol();
1554 
1555  if (!initSocketLayer(protocol))
1556  return false;
1557  }
1558 
1560 #ifdef Q_OS_UNIX
1563  else
1565 #endif
1566 #ifdef Q_OS_WIN
1569  else
1573  else
1575 #endif
1576  }
1577  bool result = socketEngine->bind(address, port);
1579 
1580  if (!result) {
1582  return false;
1583  }
1584 
1588 
1589  emit q->stateChanged(state);
1590  // A slot attached to stateChanged() signal can break our invariant:
1591  // by closing the socket it will reset its socket engine - thus we
1592  // have additional check (isValid()) ...
1593  if (q->isValid() && socketType == QAbstractSocket::UdpSocket)
1595  return true;
1596 }
1597 
1620 #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
1621 bool QAbstractSocket::bind(quint16 port, BindMode mode)
1622 {
1623  return bind(QHostAddress::Any, port, mode);
1624 }
1625 #endif
1626 
1637 {
1638  return d_func()->socketEngine ? d_func()->socketEngine->isValid() : isOpen();
1639 }
1640 
1665  OpenMode openMode,
1666  NetworkLayerProtocol protocol)
1667 {
1668  Q_D(QAbstractSocket);
1669 #if defined(QABSTRACTSOCKET_DEBUG)
1670  qDebug("QAbstractSocket::connectToHost(\"%s\", %i, %i)...", qPrintable(hostName), port,
1671  (int) openMode);
1672 #endif
1673 
1674  if (d->state == ConnectedState || d->state == ConnectingState
1675  || d->state == ClosingState || d->state == HostLookupState) {
1676  qWarning("QAbstractSocket::connectToHost() called when already looking up or connecting/connected to \"%s\"", qPrintable(hostName));
1677  d->setErrorAndEmit(OperationError, tr("Trying to connect while connection is in progress"));
1678  return;
1679  }
1680 
1681  d->preferredNetworkLayerProtocol = protocol;
1682  d->hostName = hostName;
1683  d->port = port;
1684  d->setReadChannelCount(0);
1685  d->setWriteChannelCount(0);
1686  d->abortCalled = false;
1687  d->pendingClose = false;
1688  if (d->state != BoundState) {
1689  d->state = UnconnectedState;
1690  d->localPort = 0;
1691  d->localAddress.clear();
1692  }
1693  d->peerPort = 0;
1694  d->peerAddress.clear();
1695  d->peerName = hostName;
1696  if (d->hostLookupId != -1) {
1697  QHostInfo::abortHostLookup(d->hostLookupId);
1698  d->hostLookupId = -1;
1699  }
1700 
1701 #ifndef QT_NO_NETWORKPROXY
1702  // Get the proxy information
1703  d->resolveProxy(hostName, port);
1704  if (d->proxyInUse.type() == QNetworkProxy::DefaultProxy) {
1705  // failed to setup the proxy
1706  d->setErrorAndEmit(UnsupportedSocketOperationError,
1707  tr("Operation on socket is not supported"));
1708  return;
1709  }
1710 #endif
1711 
1712  // Sync up with error string, which open() shall clear.
1713  d->socketError = UnknownSocketError;
1715  d->isBuffered = false;
1716  else if (!d_func()->isBuffered)
1718 
1720  d->readChannelCount = d->writeChannelCount = 0;
1721 
1722  d->state = HostLookupState;
1723  emit stateChanged(d->state);
1724 
1725  QHostAddress temp;
1726  if (temp.setAddress(hostName)) {
1727  QHostInfo info;
1728  info.setAddresses(QList<QHostAddress>() << temp);
1729  d->_q_startConnecting(info);
1730 #ifndef QT_NO_NETWORKPROXY
1731  } else if (d->proxyInUse.capabilities() & QNetworkProxy::HostNameLookupCapability) {
1732  // the proxy supports connection by name, so use it
1733  d->startConnectingByName(hostName);
1734  return;
1735 #endif
1736  } else {
1737  if (d->threadData.loadRelaxed()->hasEventDispatcher()) {
1738  // this internal API for QHostInfo either immediately gives us the desired
1739  // QHostInfo from cache or later calls the _q_startConnecting slot.
1740  bool immediateResultValid = false;
1741  QHostInfo hostInfo = qt_qhostinfo_lookup(hostName,
1742  this,
1743  SLOT(_q_startConnecting(QHostInfo)),
1744  &immediateResultValid,
1745  &d->hostLookupId);
1746  if (immediateResultValid) {
1747  d->hostLookupId = -1;
1748  d->_q_startConnecting(hostInfo);
1749  }
1750  }
1751  }
1752 
1753 #if defined(QABSTRACTSOCKET_DEBUG)
1754  qDebug("QAbstractSocket::connectToHost(\"%s\", %i) == %s%s", hostName.toLatin1().constData(), port,
1755  (d->state == ConnectedState) ? "true" : "false",
1756  (d->state == ConnectingState || d->state == HostLookupState)
1757  ? " (connection in progress)" : "");
1758 #endif
1759 }
1760 
1766  OpenMode openMode)
1767 {
1768 #if defined(QABSTRACTSOCKET_DEBUG)
1769  qDebug("QAbstractSocket::connectToHost([%s], %i, %i)...",
1770  address.toString().toLatin1().constData(), port, (int) openMode);
1771 #endif
1772  connectToHost(address.toString(), port, openMode);
1773 }
1774 
1783 {
1784  const qint64 pendingBytes = QIODevice::bytesToWrite();
1785 #if defined(QABSTRACTSOCKET_DEBUG)
1786  qDebug("QAbstractSocket::bytesToWrite() == %lld", pendingBytes);
1787 #endif
1788  return pendingBytes;
1789 }
1790 
1797 {
1798  Q_D(const QAbstractSocket);
1799  qint64 available = QIODevice::bytesAvailable();
1800 
1801  if (!d->isBuffered && d->socketEngine && d->socketEngine->isValid())
1802  available += d->socketEngine->bytesAvailable();
1803 
1804 #if defined(QABSTRACTSOCKET_DEBUG)
1805  qDebug("QAbstractSocket::bytesAvailable() == %lld", available);
1806 #endif
1807  return available;
1808 }
1809 
1817 {
1818  Q_D(const QAbstractSocket);
1819  return d->localPort;
1820 }
1821 
1833 {
1834  Q_D(const QAbstractSocket);
1835  return d->localAddress;
1836 }
1837 
1845 {
1846  Q_D(const QAbstractSocket);
1847  return d->peerPort;
1848 }
1849 
1857 {
1858  Q_D(const QAbstractSocket);
1859  return d->peerAddress;
1860 }
1861 
1869 {
1870  Q_D(const QAbstractSocket);
1871  return d->peerName.isEmpty() ? d->hostName : d->peerName;
1872 }
1873 
1887 {
1888  Q_D(const QAbstractSocket);
1889  return d->cachedSocketDescriptor;
1890 }
1891 
1905 bool QAbstractSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState socketState,
1906  OpenMode openMode)
1907 {
1908  Q_D(QAbstractSocket);
1909 
1910  d->resetSocketLayer();
1911  d->setReadChannelCount(0);
1912  d->setWriteChannelCount(0);
1914  if (!d->socketEngine) {
1915  d->setError(UnsupportedSocketOperationError, tr("Operation on socket is not supported"));
1916  return false;
1917  }
1918  bool result = d->socketEngine->initialize(socketDescriptor, socketState);
1919  if (!result) {
1920  d->setError(d->socketEngine->error(), d->socketEngine->errorString());
1921  return false;
1922  }
1923 
1924  // Sync up with error string, which open() shall clear.
1925  d->socketError = UnknownSocketError;
1926  if (d->threadData.loadRelaxed()->hasEventDispatcher())
1927  d->socketEngine->setReceiver(d);
1928 
1930 
1931  if (socketState == ConnectedState) {
1932  if (isReadable()) {
1933  const int inboundStreamCount = d->socketEngine->inboundStreamCount();
1934  d->setReadChannelCount(qMax(1, inboundStreamCount));
1935  if (inboundStreamCount == 0)
1936  d->readChannelCount = 0;
1937  }
1938  if (isWritable()) {
1939  const int outboundStreamCount = d->socketEngine->outboundStreamCount();
1940  d->setWriteChannelCount(qMax(1, outboundStreamCount));
1941  if (outboundStreamCount == 0)
1942  d->writeChannelCount = 0;
1943  }
1944  } else {
1945  d->readChannelCount = d->writeChannelCount = 0;
1946  }
1947 
1948  if (d->state != socketState) {
1949  d->state = socketState;
1950  emit stateChanged(d->state);
1951  }
1952 
1953  d->pendingClose = false;
1954  d->socketEngine->setReadNotificationEnabled(true);
1955  d->localPort = d->socketEngine->localPort();
1956  d->peerPort = d->socketEngine->peerPort();
1957  d->localAddress = d->socketEngine->localAddress();
1958  d->peerAddress = d->socketEngine->peerAddress();
1959  d->cachedSocketDescriptor = socketDescriptor;
1960 
1961  return true;
1962 }
1963 
1975 {
1976  if (!d_func()->socketEngine)
1977  return;
1978 
1979  switch (option) {
1980  case LowDelayOption:
1981  d_func()->socketEngine->setOption(QAbstractSocketEngine::LowDelayOption, value.toInt());
1982  break;
1983 
1984  case KeepAliveOption:
1985  d_func()->socketEngine->setOption(QAbstractSocketEngine::KeepAliveOption, value.toInt());
1986  break;
1987 
1988  case MulticastTtlOption:
1989  d_func()->socketEngine->setOption(QAbstractSocketEngine::MulticastTtlOption, value.toInt());
1990  break;
1991 
1993  d_func()->socketEngine->setOption(QAbstractSocketEngine::MulticastLoopbackOption, value.toInt());
1994  break;
1995 
1996  case TypeOfServiceOption:
1997  d_func()->socketEngine->setOption(QAbstractSocketEngine::TypeOfServiceOption, value.toInt());
1998  break;
1999 
2001  d_func()->socketEngine->setOption(QAbstractSocketEngine::SendBufferSocketOption, value.toInt());
2002  break;
2003 
2005  d_func()->socketEngine->setOption(QAbstractSocketEngine::ReceiveBufferSocketOption, value.toInt());
2006  break;
2007 
2008  case PathMtuSocketOption:
2009  d_func()->socketEngine->setOption(QAbstractSocketEngine::PathMtuInformation, value.toInt());
2010  break;
2011  }
2012 }
2013 
2021 {
2022  if (!d_func()->socketEngine)
2023  return QVariant();
2024 
2025  int ret = -1;
2026  switch (option) {
2027  case LowDelayOption:
2028  ret = d_func()->socketEngine->option(QAbstractSocketEngine::LowDelayOption);
2029  break;
2030 
2031  case KeepAliveOption:
2032  ret = d_func()->socketEngine->option(QAbstractSocketEngine::KeepAliveOption);
2033  break;
2034 
2035  case MulticastTtlOption:
2036  ret = d_func()->socketEngine->option(QAbstractSocketEngine::MulticastTtlOption);
2037  break;
2039  ret = d_func()->socketEngine->option(QAbstractSocketEngine::MulticastLoopbackOption);
2040  break;
2041 
2042  case TypeOfServiceOption:
2043  ret = d_func()->socketEngine->option(QAbstractSocketEngine::TypeOfServiceOption);
2044  break;
2045 
2047  ret = d_func()->socketEngine->option(QAbstractSocketEngine::SendBufferSocketOption);
2048  break;
2049 
2051  ret = d_func()->socketEngine->option(QAbstractSocketEngine::ReceiveBufferSocketOption);
2052  break;
2053 
2054  case PathMtuSocketOption:
2055  ret = d_func()->socketEngine->option(QAbstractSocketEngine::PathMtuInformation);
2056  break;
2057  }
2058  if (ret == -1)
2059  return QVariant();
2060  else
2061  return QVariant(ret);
2062 }
2063 
2090 {
2091  Q_D(QAbstractSocket);
2092 #if defined (QABSTRACTSOCKET_DEBUG)
2093  qDebug("QAbstractSocket::waitForConnected(%i)", msecs);
2094 #endif
2095 
2096  if (state() == ConnectedState) {
2097 #if defined (QABSTRACTSOCKET_DEBUG)
2098  qDebug("QAbstractSocket::waitForConnected(%i) already connected", msecs);
2099 #endif
2100  return true;
2101  }
2102 
2103  bool wasPendingClose = d->pendingClose;
2104  d->pendingClose = false;
2105  QElapsedTimer stopWatch;
2106  stopWatch.start();
2107 
2108  if (d->state == HostLookupState) {
2109 #if defined (QABSTRACTSOCKET_DEBUG)
2110  qDebug("QAbstractSocket::waitForConnected(%i) doing host name lookup", msecs);
2111 #endif
2112  QHostInfo::abortHostLookup(d->hostLookupId);
2113  d->hostLookupId = -1;
2114  QHostAddress temp;
2115  if (temp.setAddress(d->hostName)) {
2116  QHostInfo info;
2117  info.setAddresses(QList<QHostAddress>() << temp);
2118  d->_q_startConnecting(info);
2119  } else {
2120  d->_q_startConnecting(QHostInfo::fromName(d->hostName));
2121  }
2122  }
2123  if (state() == UnconnectedState)
2124  return false; // connect not im progress anymore!
2125 
2126  int connectTimeout = DefaultConnectTimeout;
2127  bool timedOut = true;
2128 #if defined (QABSTRACTSOCKET_DEBUG)
2129  int attempt = 1;
2130 #endif
2131  while (state() == ConnectingState && (msecs == -1 || stopWatch.elapsed() < msecs)) {
2132  int timeout = qt_subtract_from_timeout(msecs, stopWatch.elapsed());
2133  if (msecs != -1 && timeout > connectTimeout)
2134  timeout = connectTimeout;
2135 #if defined (QABSTRACTSOCKET_DEBUG)
2136  qDebug("QAbstractSocket::waitForConnected(%i) waiting %.2f secs for connection attempt #%i",
2137  msecs, timeout / 1000.0, attempt++);
2138 #endif
2139  timedOut = false;
2140 
2141  if (d->socketEngine && d->socketEngine->waitForWrite(timeout, &timedOut) && !timedOut) {
2142  d->_q_testConnection();
2143  } else {
2144  d->_q_connectToNextAddress();
2145  }
2146  }
2147 
2148  if ((timedOut && state() != ConnectedState) || state() == ConnectingState) {
2149  d->setError(SocketTimeoutError, tr("Socket operation timed out"));
2150  d->state = UnconnectedState;
2151  emit stateChanged(d->state);
2152  d->resetSocketLayer();
2153  }
2154 
2155 #if defined (QABSTRACTSOCKET_DEBUG)
2156  qDebug("QAbstractSocket::waitForConnected(%i) == %s", msecs,
2157  state() == ConnectedState ? "true" : "false");
2158 #endif
2159  if (state() != ConnectedState)
2160  return false;
2161  if (wasPendingClose)
2163  return true;
2164 }
2165 
2182 {
2183  Q_D(QAbstractSocket);
2184 #if defined (QABSTRACTSOCKET_DEBUG)
2185  qDebug("QAbstractSocket::waitForReadyRead(%i)", msecs);
2186 #endif
2187 
2188  // require calling connectToHost() before waitForReadyRead()
2189  if (state() == UnconnectedState) {
2190  /* If all you have is a QIODevice pointer to an abstractsocket, you cannot check
2191  this, so you cannot avoid this warning. */
2192 // qWarning("QAbstractSocket::waitForReadyRead() is not allowed in UnconnectedState");
2193  return false;
2194  }
2195 
2196  QElapsedTimer stopWatch;
2197  stopWatch.start();
2198 
2199  // handle a socket in connecting state
2200  if (state() == HostLookupState || state() == ConnectingState) {
2201  if (!waitForConnected(msecs))
2202  return false;
2203  }
2204 
2205  do {
2206  if (state() != ConnectedState && state() != BoundState)
2207  return false;
2208  Q_ASSERT(d->socketEngine);
2209 
2210  bool readyToRead = false;
2211  bool readyToWrite = false;
2212  if (!d->socketEngine->waitForReadOrWrite(&readyToRead, &readyToWrite, true, !d->writeBuffer.isEmpty(),
2213  qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) {
2214 #if defined (QABSTRACTSOCKET_DEBUG)
2215  qDebug("QAbstractSocket::waitForReadyRead(%i) failed (%i, %s)",
2216  msecs, d->socketEngine->error(), d->socketEngine->errorString().toLatin1().constData());
2217 #endif
2218  d->setErrorAndEmit(d->socketEngine->error(), d->socketEngine->errorString());
2219  if (d->socketError != SocketTimeoutError)
2220  close();
2221  return false;
2222  }
2223 
2224  if (readyToRead) {
2225  if (d->canReadNotification())
2226  return true;
2227  }
2228 
2229  if (readyToWrite)
2230  d->canWriteNotification();
2231  } while (msecs == -1 || qt_subtract_from_timeout(msecs, stopWatch.elapsed()) > 0);
2232  return false;
2233 }
2234 
2252 {
2253  Q_D(QAbstractSocket);
2254 #if defined (QABSTRACTSOCKET_DEBUG)
2255  qDebug("QAbstractSocket::waitForBytesWritten(%i)", msecs);
2256 #endif
2257 
2258  // require calling connectToHost() before waitForBytesWritten()
2259  if (state() == UnconnectedState) {
2260  qWarning("QAbstractSocket::waitForBytesWritten() is not allowed in UnconnectedState");
2261  return false;
2262  }
2263 
2264  if (d->writeBuffer.isEmpty())
2265  return false;
2266 
2267  QElapsedTimer stopWatch;
2268  stopWatch.start();
2269 
2270  // handle a socket in connecting state
2271  if (state() == HostLookupState || state() == ConnectingState) {
2272  if (!waitForConnected(msecs))
2273  return false;
2274  }
2275 
2276  forever {
2277  bool readyToRead = false;
2278  bool readyToWrite = false;
2279  if (!d->socketEngine->waitForReadOrWrite(&readyToRead, &readyToWrite,
2280  !d->readBufferMaxSize || d->buffer.size() < d->readBufferMaxSize,
2281  !d->writeBuffer.isEmpty(),
2282  qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) {
2283 #if defined (QABSTRACTSOCKET_DEBUG)
2284  qDebug("QAbstractSocket::waitForBytesWritten(%i) failed (%i, %s)",
2285  msecs, d->socketEngine->error(), d->socketEngine->errorString().toLatin1().constData());
2286 #endif
2287  d->setErrorAndEmit(d->socketEngine->error(), d->socketEngine->errorString());
2288  if (d->socketError != SocketTimeoutError)
2289  close();
2290  return false;
2291  }
2292 
2293  if (readyToRead) {
2294 #if defined (QABSTRACTSOCKET_DEBUG)
2295  qDebug("QAbstractSocket::waitForBytesWritten calls canReadNotification");
2296 #endif
2297  d->canReadNotification();
2298  }
2299 
2300 
2301  if (readyToWrite) {
2302  if (d->canWriteNotification()) {
2303 #if defined (QABSTRACTSOCKET_DEBUG)
2304  qDebug("QAbstractSocket::waitForBytesWritten returns true");
2305 #endif
2306  return true;
2307  }
2308  }
2309 
2310  if (state() != ConnectedState)
2311  return false;
2312  }
2313  return false;
2314 }
2315 
2337 {
2338  Q_D(QAbstractSocket);
2339 
2340  // require calling connectToHost() before waitForDisconnected()
2341  if (state() == UnconnectedState) {
2342  qWarning("QAbstractSocket::waitForDisconnected() is not allowed in UnconnectedState");
2343  return false;
2344  }
2345 
2346  QElapsedTimer stopWatch;
2347  stopWatch.start();
2348 
2349  // handle a socket in connecting state
2350  if (state() == HostLookupState || state() == ConnectingState) {
2351  if (!waitForConnected(msecs))
2352  return false;
2353  if (state() == UnconnectedState)
2354  return true;
2355  }
2356 
2357  forever {
2358  bool readyToRead = false;
2359  bool readyToWrite = false;
2360  if (!d->socketEngine->waitForReadOrWrite(&readyToRead, &readyToWrite, state() == ConnectedState,
2361  !d->writeBuffer.isEmpty(),
2362  qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) {
2363 #if defined (QABSTRACTSOCKET_DEBUG)
2364  qDebug("QAbstractSocket::waitForReadyRead(%i) failed (%i, %s)",
2365  msecs, d->socketEngine->error(), d->socketEngine->errorString().toLatin1().constData());
2366 #endif
2367  d->setErrorAndEmit(d->socketEngine->error(), d->socketEngine->errorString());
2368  if (d->socketError != SocketTimeoutError)
2369  close();
2370  return false;
2371  }
2372 
2373  if (readyToRead)
2374  d->canReadNotification();
2375  if (readyToWrite)
2376  d->canWriteNotification();
2377 
2378  if (state() == UnconnectedState)
2379  return true;
2380  }
2381  return false;
2382 }
2383 
2392 {
2393  Q_D(QAbstractSocket);
2394 #if defined (QABSTRACTSOCKET_DEBUG)
2395  qDebug("QAbstractSocket::abort()");
2396 #endif
2397  d->setWriteChannelCount(0);
2398  d->abortCalled = true;
2399  close();
2400 }
2401 
2405 {
2406  return true;
2407 }
2408 
2424 {
2425  return d_func()->flush();
2426 }
2427 
2431 {
2432  Q_D(QAbstractSocket);
2433 
2434  // if we're not connected, return -1 indicating EOF
2435  if (!d->socketEngine || !d->socketEngine->isValid() || d->state != QAbstractSocket::ConnectedState)
2436  return maxSize ? qint64(-1) : qint64(0);
2437 
2438  qint64 readBytes = (maxSize && !d->isBuffered) ? d->socketEngine->read(data, maxSize)
2439  : qint64(0);
2440  if (readBytes == -2) {
2441  // -2 from the engine means no bytes available (EAGAIN) so read more later
2442  readBytes = 0;
2443  }
2444  if (readBytes < 0) {
2445  d->setError(d->socketEngine->error(), d->socketEngine->errorString());
2446  d->resetSocketLayer();
2448  } else {
2449  // Only do this when there was no error
2450  d->hasPendingData = false;
2451  d->socketEngine->setReadNotificationEnabled(true);
2452  }
2453 
2454 #if defined (QABSTRACTSOCKET_DEBUG)
2455  qDebug("QAbstractSocket::readData(%p \"%s\", %lli) == %lld [engine]", data,
2456  QtDebugUtils::toPrintable(data, readBytes, 32).constData(), maxSize, readBytes);
2457 #endif
2458  return readBytes;
2459 }
2460 
2464 {
2465  return QIODevice::readLineData(data, maxlen);
2466 }
2467 
2471 {
2472  Q_D(QAbstractSocket);
2473  if (d->state == QAbstractSocket::UnconnectedState
2474  || (!d->socketEngine && d->socketType != TcpSocket && !d->isBuffered)) {
2475  d->setError(UnknownSocketError, tr("Socket is not connected"));
2476  return -1;
2477  }
2478 
2479  if (!d->isBuffered && d->socketType == TcpSocket
2480  && d->socketEngine && d->writeBuffer.isEmpty()) {
2481  // This code is for the new Unbuffered QTcpSocket use case
2482  qint64 written = size ? d->socketEngine->write(data, size) : Q_INT64_C(0);
2483  if (written < 0) {
2484  d->setError(d->socketEngine->error(), d->socketEngine->errorString());
2485  } else if (written < size) {
2486  // Buffer what was not written yet
2487  d->writeBuffer.append(data + written, size - written);
2488  written = size;
2489  d->socketEngine->setWriteNotificationEnabled(true);
2490  }
2491 
2492 #if defined (QABSTRACTSOCKET_DEBUG)
2493  qDebug("QAbstractSocket::writeData(%p \"%s\", %lli) == %lli", data,
2494  QtDebugUtils::toPrintable(data, size, 32).constData(), size, written);
2495 #endif
2496  return written; // written = actually written + what has been buffered
2497  } else if (!d->isBuffered && d->socketType != TcpSocket) {
2498  // This is for a QUdpSocket that was connect()ed
2499  qint64 written = d->socketEngine->write(data, size);
2500  if (written < 0)
2501  d->setError(d->socketEngine->error(), d->socketEngine->errorString());
2502 
2503 #if defined (QABSTRACTSOCKET_DEBUG)
2504  qDebug("QAbstractSocket::writeData(%p \"%s\", %lli) == %lli", data,
2505  QtDebugUtils::toPrintable(data, size, 32).constData(), size, written);
2506 #endif
2507  if (written >= 0)
2508  d->emitBytesWritten(written);
2509  return written;
2510  }
2511 
2512  // This is the code path for normal buffered QTcpSocket or
2513  // unbuffered QTcpSocket when there was already something in the
2514  // write buffer and therefore we could not do a direct engine write.
2515  // We just write to our write buffer and enable the write notifier
2516  // The write notifier then flush()es the buffer.
2517 
2518  d->write(data, size);
2519  qint64 written = size;
2520 
2521  if (d->socketEngine && !d->writeBuffer.isEmpty())
2522  d->socketEngine->setWriteNotificationEnabled(true);
2523 
2524 #if defined (QABSTRACTSOCKET_DEBUG)
2525  qDebug("QAbstractSocket::writeData(%p \"%s\", %lli) == %lli", data,
2526  QtDebugUtils::toPrintable(data, size, 32).constData(), size, written);
2527 #endif
2528  return written;
2529 }
2530 
2547 {
2548  Q_D(QAbstractSocket);
2549  d->localPort = port;
2550 }
2551 
2569 {
2570  Q_D(QAbstractSocket);
2571  d->localAddress = address;
2572 }
2573 
2588 {
2589  Q_D(QAbstractSocket);
2590  d->peerPort = port;
2591 }
2592 
2607 {
2608  Q_D(QAbstractSocket);
2609  d->peerAddress = address;
2610 }
2611 
2625 {
2626  Q_D(QAbstractSocket);
2627  d->peerName = name;
2628 }
2629 
2640 {
2641  Q_D(QAbstractSocket);
2642 #if defined(QABSTRACTSOCKET_DEBUG)
2643  qDebug("QAbstractSocket::close()");
2644 #endif
2645  QIODevice::close();
2646  if (d->state != UnconnectedState)
2648 }
2649 
2659 {
2660  Q_D(QAbstractSocket);
2661 #if defined(QABSTRACTSOCKET_DEBUG)
2662  qDebug("QAbstractSocket::disconnectFromHost()");
2663 #endif
2664 
2665  if (d->state == UnconnectedState) {
2666 #if defined(QABSTRACTSOCKET_DEBUG)
2667  qDebug("QAbstractSocket::disconnectFromHost() was called on an unconnected socket");
2668 #endif
2669  return;
2670  }
2671 
2672  if (!d->abortCalled && (d->state == ConnectingState || d->state == HostLookupState)) {
2673 #if defined(QABSTRACTSOCKET_DEBUG)
2674  qDebug("QAbstractSocket::disconnectFromHost() but we're still connecting");
2675 #endif
2676  d->pendingClose = true;
2677  return;
2678  }
2679 
2680  // Disable and delete read notification
2681  if (d->socketEngine)
2682  d->socketEngine->setReadNotificationEnabled(false);
2683 
2684  if (d->abortCalled) {
2685 #if defined(QABSTRACTSOCKET_DEBUG)
2686  qDebug("QAbstractSocket::disconnectFromHost() aborting immediately");
2687 #endif
2688  if (d->state == HostLookupState) {
2689  QHostInfo::abortHostLookup(d->hostLookupId);
2690  d->hostLookupId = -1;
2691  }
2692  } else {
2693  // Perhaps emit closing()
2694  if (d->state != ClosingState) {
2695  d->state = ClosingState;
2696 #if defined(QABSTRACTSOCKET_DEBUG)
2697  qDebug("QAbstractSocket::disconnectFromHost() emits stateChanged()(ClosingState)");
2698 #endif
2699  emit stateChanged(d->state);
2700  } else {
2701 #if defined(QABSTRACTSOCKET_DEBUG)
2702  qDebug("QAbstractSocket::disconnectFromHost() return from delayed close");
2703 #endif
2704  }
2705 
2706  // Wait for pending data to be written.
2707  if (d->socketEngine && d->socketEngine->isValid() && (!d->allWriteBuffersEmpty()
2708  || d->socketEngine->bytesToWrite() > 0)) {
2709  d->socketEngine->setWriteNotificationEnabled(true);
2710 
2711 #if defined(QABSTRACTSOCKET_DEBUG)
2712  qDebug("QAbstractSocket::disconnectFromHost() delaying disconnect");
2713 #endif
2714  return;
2715  } else {
2716 #if defined(QABSTRACTSOCKET_DEBUG)
2717  qDebug("QAbstractSocket::disconnectFromHost() disconnecting immediately");
2718 #endif
2719  }
2720  }
2721 
2722  SocketState previousState = d->state;
2723  d->resetSocketLayer();
2724  d->state = UnconnectedState;
2725  emit stateChanged(d->state);
2726  emit readChannelFinished(); // we got an EOF
2727 
2728  // only emit disconnected if we were connected before
2729  if (previousState == ConnectedState || previousState == ClosingState)
2730  emit disconnected();
2731 
2732  d->localPort = 0;
2733  d->peerPort = 0;
2734  d->localAddress.clear();
2735  d->peerAddress.clear();
2736  d->peerName.clear();
2737  d->setWriteChannelCount(0);
2738 
2739 #if defined(QABSTRACTSOCKET_DEBUG)
2740  qDebug("QAbstractSocket::disconnectFromHost() disconnected!");
2741 #endif
2742 
2743 }
2744 
2756 {
2757  return d_func()->readBufferMaxSize;
2758 }
2759 
2783 {
2784  Q_D(QAbstractSocket);
2785 
2786  if (d->readBufferMaxSize == size)
2787  return;
2788  d->readBufferMaxSize = size;
2789 
2790  // Do not change the notifier unless we are connected.
2791  if (d->socketEngine && d->state == QAbstractSocket::ConnectedState) {
2792  // Ensure that the read notification is enabled if we've now got
2793  // room in the read buffer.
2794  d->socketEngine->setReadNotificationEnabled(size == 0 || d->buffer.size() < size);
2795  }
2796 }
2797 
2804 {
2805  return d_func()->state;
2806 }
2807 
2814 {
2815  d_func()->state = state;
2816 }
2817 
2824 {
2825  return d_func()->socketType;
2826 }
2827 
2834 {
2835  return d_func()->socketError;
2836 }
2837 
2844 {
2845  d_func()->socketError = socketError;
2846 }
2847 
2848 #ifndef QT_NO_NETWORKPROXY
2868 void QAbstractSocket::setProxy(const QNetworkProxy &networkProxy)
2869 {
2870  Q_D(QAbstractSocket);
2871  d->proxy = networkProxy;
2872 }
2873 
2884 {
2885  Q_D(const QAbstractSocket);
2886  return d->proxy;
2887 }
2888 
2901 {
2902  Q_D(const QAbstractSocket);
2903  return d->protocolTag;
2904 }
2905 
2915 {
2916  Q_D(QAbstractSocket);
2917  d->protocolTag = tag;
2918 }
2919 
2920 #endif // QT_NO_NETWORKPROXY
2921 
2922 #ifndef QT_NO_DEBUG_STREAM
2924 {
2925  QDebugStateSaver saver(debug);
2926  debug.resetFormat().nospace();
2927  switch (error) {
2929  debug << "QAbstractSocket::ConnectionRefusedError";
2930  break;
2932  debug << "QAbstractSocket::RemoteHostClosedError";
2933  break;
2935  debug << "QAbstractSocket::HostNotFoundError";
2936  break;
2938  debug << "QAbstractSocket::SocketAccessError";
2939  break;
2941  debug << "QAbstractSocket::SocketResourceError";
2942  break;
2944  debug << "QAbstractSocket::SocketTimeoutError";
2945  break;
2947  debug << "QAbstractSocket::DatagramTooLargeError";
2948  break;
2950  debug << "QAbstractSocket::NetworkError";
2951  break;
2953  debug << "QAbstractSocket::AddressInUseError";
2954  break;
2956  debug << "QAbstractSocket::SocketAddressNotAvailableError";
2957  break;
2959  debug << "QAbstractSocket::UnsupportedSocketOperationError";
2960  break;
2962  debug << "QAbstractSocket::UnfinishedSocketOperationError";
2963  break;
2965  debug << "QAbstractSocket::ProxyAuthenticationRequiredError";
2966  break;
2968  debug << "QAbstractSocket::UnknownSocketError";
2969  break;
2971  debug << "QAbstractSocket::ProxyConnectionRefusedError";
2972  break;
2974  debug << "QAbstractSocket::ProxyConnectionClosedError";
2975  break;
2977  debug << "QAbstractSocket::ProxyConnectionTimeoutError";
2978  break;
2980  debug << "QAbstractSocket::ProxyNotFoundError";
2981  break;
2983  debug << "QAbstractSocket::ProxyProtocolError";
2984  break;
2985  default:
2986  debug << "QAbstractSocket::SocketError(" << int(error) << ')';
2987  break;
2988  }
2989  return debug;
2990 }
2991 
2993 {
2994  QDebugStateSaver saver(debug);
2995  debug.resetFormat().nospace();
2996  switch (state) {
2998  debug << "QAbstractSocket::UnconnectedState";
2999  break;
3001  debug << "QAbstractSocket::HostLookupState";
3002  break;
3004  debug << "QAbstractSocket::ConnectingState";
3005  break;
3007  debug << "QAbstractSocket::ConnectedState";
3008  break;
3010  debug << "QAbstractSocket::BoundState";
3011  break;
3013  debug << "QAbstractSocket::ListeningState";
3014  break;
3016  debug << "QAbstractSocket::ClosingState";
3017  break;
3018  default:
3019  debug << "QAbstractSocket::SocketState(" << int(state) << ')';
3020  break;
3021  }
3022  return debug;
3023 }
3024 #endif
3025 
3027 
3028 #include "moc_qabstractsocket.cpp"
small capitals from c petite p scientific i
[1]
Definition: afcover.h:80
FT_Error error
Definition: cffdrivr.c:657
QAbstractSocket::SocketError error() const
virtual void setWriteNotificationEnabled(bool enable)=0
virtual bool bind(const QHostAddress &address, quint16 port)=0
virtual bool isValid() const =0
virtual bool isReadNotificationEnabled() const =0
void setReceiver(QAbstractSocketEngineReceiver *receiver)
virtual bool connectToHost(const QHostAddress &address, quint16 port)=0
virtual bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol=QAbstractSocket::IPv4Protocol)=0
QAbstractSocket::SocketType socketType() const
virtual qint64 read(char *data, qint64 maxlen)=0
virtual void setReadNotificationEnabled(bool enable)=0
static QAbstractSocketEngine * createSocketEngine(QAbstractSocket::SocketType socketType, const QNetworkProxy &, QObject *parent)
virtual bool setOption(SocketOption option, int value)=0
virtual qint64 write(const char *data, qint64 len)=0
QAbstractSocket::SocketState state() const
virtual qintptr socketDescriptor() const =0
virtual bool connectToHostByName(const QString &name, quint16 port)=0
virtual qint64 bytesAvailable() const =0
virtual qint64 bytesToWrite() const =0
virtual void setExceptionNotificationEnabled(bool enable)=0
virtual bool isWriteNotificationEnabled() const =0
QHostAddress peerAddress() const
virtual void close()=0
virtual bool isExceptionNotificationEnabled() const =0
QHostAddress localAddress() const
The QAbstractSocket class provides the base functionality common to all socket types.
bool isSequential() const override
QAbstractSocket(SocketType socketType, QObject *parent)
void stateChanged(QAbstractSocket::SocketState)
virtual void setReadBufferSize(qint64 size)
quint16 peerPort() const
static constexpr auto IPv4Protocol
virtual void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value)
virtual QVariant socketOption(QAbstractSocket::SocketOption option)
void setPauseMode(PauseModes pauseMode)
bool waitForReadyRead(int msecs=30000) override
qint64 bytesToWrite() const override
qint64 readLineData(char *data, qint64 maxlen) override
bool waitForBytesWritten(int msecs=30000) override
virtual qintptr socketDescriptor() const
virtual bool waitForDisconnected(int msecs=30000)
QString protocolTag() const
void setSocketError(SocketError socketError)
void setPeerPort(quint16 port)
virtual ~QAbstractSocket()
qint64 bytesAvailable() const override
QHostAddress localAddress() const
QString peerName() const
qint64 skipData(qint64 maxSize) override
QNetworkProxy proxy() const
virtual bool bind(const QHostAddress &address, quint16 port=0, BindMode mode=DefaultForPlatform)
virtual bool waitForConnected(int msecs=30000)
PauseModes pauseMode() const
virtual void disconnectFromHost()
void setPeerAddress(const QHostAddress &address)
static constexpr auto UnknownNetworkLayerProtocol
void setProxy(const QNetworkProxy &networkProxy)
static constexpr auto AnyIPProtocol
qint64 writeData(const char *data, qint64 len) override
qint64 readBufferSize() const
void setLocalPort(quint16 port)
void setProtocolTag(const QString &tag)
SocketType socketType() const
bool isValid() const
void close() override
void setLocalAddress(const QHostAddress &address)
SocketState state() const
void setSocketState(SocketState state)
static constexpr auto IPv6Protocol
virtual void connectToHost(const QString &hostName, quint16 port, OpenMode mode=ReadWrite, NetworkLayerProtocol protocol=AnyIPProtocol)
quint16 localPort() const
void setPeerName(const QString &name)
virtual void resume()
SocketError error() const
QHostAddress peerAddress() const
virtual bool setSocketDescriptor(qintptr socketDescriptor, SocketState state=ConnectedState, OpenMode openMode=ReadWrite)
qint64 readData(char *data, qint64 maxlen) override
QList< QHostAddress > addresses
void setError(QAbstractSocket::SocketError errorCode, const QString &errorString)
void emitBytesWritten(qint64 bytes, int channel=0)
QAbstractSocket::NetworkLayerProtocol preferredNetworkLayerProtocol
void emitReadyRead(int channel=0)
QAbstractSocket::SocketError socketError
QAbstractSocket::SocketType socketType
static QAbstractSocketEngine * getSocketEngine(QAbstractSocket *)
void _q_startConnecting(const QHostInfo &hostInfo)
QAbstractSocketEngine * socketEngine
void startConnectingByName(const QString &host)
virtual bool canReadNotification()
void resolveProxy(const QString &hostName, quint16 port)
virtual void configureCreatedSocket()
bool initSocketLayer(QAbstractSocket::NetworkLayerProtocol protocol)
static void pauseSocketNotifiers(QAbstractSocket *)
virtual bool writeToSocket()
virtual bool bind(const QHostAddress &address, quint16 port, QAbstractSocket::BindMode mode)
QAbstractSocket::SocketState state
static void resumeSocketNotifiers(QAbstractSocket *)
void connectionNotification() override
void setErrorAndEmit(QAbstractSocket::SocketError errorCode, const QString &errorString)
Type loadRelaxed() const noexcept
Definition: qbasicatomic.h:226
const char * constData() const noexcept
Definition: qbytearray.h:144
operator<<(QDataStream &ds, qfloat16 f)
Definition: qfloat16.cpp:327
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:65
Convenience class for custom QDebug operators.
Definition: qdebug.h:176
The QElapsedTimer class provides a fast way to calculate elapsed times.
Definition: qelapsedtimer.h:49
qint64 elapsed() const noexcept
void start() noexcept
The QHostAddress class provides an IP address.\inmodule QtNetwork.
Definition: qhostaddress.h:74
void setAddress(quint32 ip4Addr)
QString toString() const
NetworkLayerProtocol protocol() const
The QHostInfo class provides static functions for host name lookups.
Definition: qhostinfo.h:55
static void abortHostLookup(int lookupId)
Definition: qhostinfo.cpp:357
static QHostInfo fromName(const QString &name)
Definition: qhostinfo.cpp:375
QList< QHostAddress > addresses() const
Definition: qhostinfo.cpp:626
int lookupId() const
Definition: qhostinfo.cpp:693
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:70
virtual bool open(QIODeviceBase::OpenMode mode)
Definition: qiodevice.cpp:798
virtual qint64 size() const
Definition: qiodevice.cpp:874
bool isOpen() const
Definition: qiodevice.cpp:602
bool isReadable() const
Definition: qiodevice.cpp:616
QIODeviceBase::OpenMode openMode() const
Definition: qiodevice.cpp:538
virtual qint64 bytesAvailable() const
Definition: qiodevice.cpp:995
virtual qint64 skipData(qint64 maxSize)
Definition: qiodevice.cpp:2086
bool isWritable() const
Definition: qiodevice.cpp:630
virtual qint64 readLineData(char *data, qint64 maxlen)
Definition: qiodevice.cpp:1540
virtual qint64 bytesToWrite() const
Definition: qiodevice.cpp:1012
virtual void close()
Definition: qiodevice.cpp:821
void readChannelFinished()
void write(const char *data, qint64 size)
Definition: qiodevice.cpp:1802
QString errorString
Definition: qiodevice_p.h:139
bool allWriteBuffersEmpty() const
Definition: qiodevice.cpp:782
void setReadChannelCount(int count)
Definition: qiodevice.cpp:703
qint64 read(char *data, qint64 maxSize, bool peeking=false)
Definition: qiodevice.cpp:1078
void setWriteChannelCount(int count)
Definition: qiodevice.cpp:762
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
Definition: qstring.h:84
bool isEmpty() const noexcept
Definition: qlist.h:418
const_reference at(qsizetype i) const noexcept
Definition: qlist.h:457
value_type takeFirst()
Definition: qlist.h:564
qsizetype count() const noexcept
Definition: qlist.h:415
void clear()
Definition: qlist.h:445
static QList< QNetworkProxy > proxyForQuery(const QNetworkProxyQuery &query)
The QNetworkProxy class provides a network layer proxy.
QNetworkProxy::ProxyType type() const
The QNetworkProxyQuery class is used to query the proxy settings for a socket.
Definition: qnetworkproxy.h:57
The QObject class is the base class of all Qt objects.
Definition: qobject.h:125
QObject * parent() const
Definition: qobject.h:409
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Definition: qobject.cpp:2772
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Definition: qobject.cpp:3048
QAtomicPointer< QThreadData > threadData
Definition: qobject_p.h:420
The QScopedValueRollback class resets a variable to its previous value on destruction.
The QString class provides a Unicode character string.
Definition: qstring.h:388
QByteArray toLatin1() const &
Definition: qstring.h:745
The QTimer class provides repetitive and single-shot timers.
Definition: qtimer.h:58
void start(int msec)
Definition: qtimer.cpp:259
void stop()
Definition: qtimer.cpp:277
T * data() noexcept
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:95
else opt state
[0]
#define forever
Definition: ftrandom.c:53
backing_store_ptr info
[4]
Definition: jmemsys.h:161
Q_CORE_EXPORT QByteArray toPrintable(const char *data, int len, int maxSize)
Definition: qdebug.cpp:65
@ QueuedConnection
Definition: qnamespace.h:1307
@ DirectConnection
Definition: qnamespace.h:1306
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld endif[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld SRC pixld MASK if DST_R else pixld DST_R endif if
#define QABSTRACTSOCKET_BUFFERSIZE
EGLOutputPortEXT port
EGLOutputLayerEXT EGLint EGLAttrib value
unsigned short quint16
Definition: qglobal.h:286
long long qint64
Definition: qglobal.h:298
#define Q_INT64_C(c)
Definition: qglobal.h:295
ptrdiff_t qintptr
Definition: qglobal.h:309
QHostInfo qt_qhostinfo_lookup(const QString &name, QObject *receiver, const char *member, bool *valid, int *id)
Definition: qhostinfo.cpp:1084
int qt_subtract_from_timeout(int timeout, int elapsed)
Definition: qiodevice.cpp:2233
#define qDebug
[1]
Definition: qlogging.h:177
#define qWarning
Definition: qlogging.h:179
#define SLOT(a)
Definition: qobjectdefs.h:87
#define SIGNAL(a)
Definition: qobjectdefs.h:88
GLenum mode
GLboolean r
[2]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLbitfield GLuint64 timeout
[4]
GLenum GLuint buffer
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint name
GLenum query
Definition: qopenglext.h:2738
GLuint writeBuffer
Definition: qopenglext.h:2640
GLuint GLuint64EXT address
Definition: qopenglext.h:11428
GLdouble GLdouble GLdouble GLdouble q
Definition: qopenglext.h:259
GLuint64EXT * result
[6]
Definition: qopenglext.h:10932
GLdouble s
[6]
Definition: qopenglext.h:235
GLfloat GLfloat p
[1]
Definition: qopenglext.h:12698
GLuint GLenum option
Definition: qopenglext.h:5929
#define Q_ASSERT(cond)
Definition: qrandom.cpp:84
#define tr(X)
#define emit
Definition: qtmetamacros.h:85
QObject::connect nullptr
QTcpSocket * socket
[1]
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:53
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())
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent
XmlOutput::xml_output tag(const QString &name)
Definition: xmloutput.h:154