35 public QAbstractSocketEngineReceiver
37 Q_DECLARE_PUBLIC(QAbstractSocket)
39 QAbstractSocketPrivate(
decltype(QObjectPrivateVersion) version = QObjectPrivateVersion);
40 virtual ~QAbstractSocketPrivate();
43 inline void readNotification() override { canReadNotification(); }
44 inline void writeNotification() override { canWriteNotification(); }
45 inline void exceptionNotification() override {}
46 inline void closeNotification() override { canCloseNotification(); }
47 void connectionNotification() override;
48#ifndef QT_NO_NETWORKPROXY
49 inline void proxyAuthenticationRequired(
const QNetworkProxy &proxy, QAuthenticator *authenticator) override {
51 emit q->proxyAuthenticationRequired(proxy, authenticator);
55 virtual bool bind(
const QHostAddress &address, quint16 port, QAbstractSocket::BindMode mode,
56 const QNetworkInterface *iface =
nullptr);
57 bool waitForConnected(QDeadlineTimer timer);
58 bool waitForReadyRead(QDeadlineTimer timer);
59 bool waitForBytesWritten(QDeadlineTimer timer);
60 bool waitForDisconnected(QDeadlineTimer timer);
62 virtual bool canReadNotification();
63 bool canWriteNotification();
64 void canCloseNotification();
67 void _q_connectToNextAddress();
68 void _q_startConnecting(
const QHostInfo &hostInfo);
69 void _q_testConnection();
70 void _q_abortConnectionAttempt();
72 bool emittedReadyRead =
false;
73 bool emittedBytesWritten =
false;
75 bool abortCalled =
false;
76 bool pendingClose =
false;
78 QAbstractSocket::PauseModes pauseMode = QAbstractSocket::PauseNever;
83 QList<QHostAddress> addresses;
85 quint16 localPort = 0;
87 QHostAddress localAddress;
88 QHostAddress peerAddress;
91 QAbstractSocketEngine *socketEngine =
nullptr;
92 qintptr cachedSocketDescriptor = -1;
94#ifndef QT_NO_NETWORKPROXY
96 QNetworkProxy proxyInUse;
98 void resolveProxy(
const QString &hostName, quint16 port);
100 inline void resolveProxy(
const QString &, quint16) { }
102 inline void resolveProxy(quint16 port) { resolveProxy(QString(), port); }
104 void resetSocketLayer();
105 virtual bool flush();
107 bool initSocketLayer(QAbstractSocket::NetworkLayerProtocol protocol);
108 virtual void configureCreatedSocket();
109 void startConnectingByName(
const QString &host);
110 void fetchConnectionParameters();
111 bool readFromSocket();
112 virtual bool writeToSocket();
113 void emitReadyRead(
int channel = 0);
114 void emitBytesWritten(qint64 bytes,
int channel = 0);
116 void setError(QAbstractSocket::SocketError errorCode,
const QString &errorString);
117 void setErrorAndEmit(QAbstractSocket::SocketError errorCode,
const QString &errorString);
119 qint64 readBufferMaxSize = 0;
120 bool isBuffered =
false;
121 bool hasPendingData =
false;
122 bool hasPendingDatagram =
false;
124 quint32 bytesWrittenEmissionCount = 0;
126 QTimer *connectTimer =
nullptr;
128 int hostLookupId = -1;
130 QAbstractSocket::SocketType socketType = QAbstractSocket::UnknownSocketType;
131 QAbstractSocket::SocketState state = QAbstractSocket::UnconnectedState;
134 QAbstractSocket::SocketError socketError = QAbstractSocket::UnknownSocketError;
136 QAbstractSocket::NetworkLayerProtocol preferredNetworkLayerProtocol =
137 QAbstractSocket::UnknownNetworkLayerProtocol;
139 bool prePauseReadSocketNotifierState =
false;
140 bool prePauseWriteSocketNotifierState =
false;
141 bool prePauseExceptionSocketNotifierState =
false;
142 static void pauseSocketNotifiers(QAbstractSocket*);
143 static void resumeSocketNotifiers(QAbstractSocket*);
144 static QAbstractSocketEngine* getSocketEngine(QAbstractSocket*);