qabstractsocket.sip 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. // qabstractsocket.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtNetwork Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  8. //
  9. // This file may be used under the terms of the GNU General Public License
  10. // version 3.0 as published by the Free Software Foundation and appearing in
  11. // the file LICENSE included in the packaging of this file. Please review the
  12. // following information to ensure the GNU General Public License version 3.0
  13. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  14. //
  15. // If you do not wish to use this file under the terms of the GPL version 3.0
  16. // then you may purchase a commercial license. For more information contact
  17. // info@riverbankcomputing.com.
  18. //
  19. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21. class QAbstractSocket : public QIODevice
  22. {
  23. %TypeHeaderCode
  24. #include <qabstractsocket.h>
  25. %End
  26. %ConvertToSubClassCode
  27. static struct class_graph {
  28. const char *name;
  29. sipTypeDef **type;
  30. int yes, no;
  31. } graph[] = {
  32. {sipName_QAbstractNetworkCache, &sipType_QAbstractNetworkCache, 11, 1},
  33. {sipName_QAbstractSocket, &sipType_QAbstractSocket, 12, 2},
  34. {sipName_QDnsLookup, &sipType_QDnsLookup, -1, 3},
  35. {sipName_QHttpMultiPart, &sipType_QHttpMultiPart, -1, 4},
  36. {sipName_QLocalServer, &sipType_QLocalServer, -1, 5},
  37. {sipName_QLocalSocket, &sipType_QLocalSocket, -1, 6},
  38. {sipName_QNetworkAccessManager, &sipType_QNetworkAccessManager, -1, 7},
  39. {sipName_QNetworkCookieJar, &sipType_QNetworkCookieJar, -1, 8},
  40. #if QT_VERSION >= 0x060100
  41. {sipName_QNetworkInformation, &sipType_QNetworkInformation, -1, 9},
  42. #else
  43. {0, 0, -1, 9},
  44. #endif
  45. {sipName_QNetworkReply, &sipType_QNetworkReply, -1, 10},
  46. {sipName_QTcpServer, &sipType_QTcpServer, 15, -1},
  47. {sipName_QNetworkDiskCache, &sipType_QNetworkDiskCache, -1, -1},
  48. {sipName_QTcpSocket, &sipType_QTcpSocket, 14, 13},
  49. {sipName_QUdpSocket, &sipType_QUdpSocket, -1, -1},
  50. #if defined(SIP_FEATURE_PyQt_SSL)
  51. {sipName_QSslSocket, &sipType_QSslSocket, -1, -1},
  52. #else
  53. {0, 0, -1, -1},
  54. #endif
  55. #if QT_VERSION >= 0x060400 && defined(SIP_FEATURE_PyQt_SSL)
  56. {sipName_QSslServer, &sipType_QSslServer, -1, -1},
  57. #else
  58. {0, 0, -1, -1},
  59. #endif
  60. };
  61. int i = 0;
  62. sipType = NULL;
  63. do
  64. {
  65. struct class_graph *cg = &graph[i];
  66. if (cg->name != NULL && sipCpp->inherits(cg->name))
  67. {
  68. sipType = *cg->type;
  69. i = cg->yes;
  70. }
  71. else
  72. i = cg->no;
  73. }
  74. while (i >= 0);
  75. %End
  76. public:
  77. enum SocketType
  78. {
  79. TcpSocket,
  80. UdpSocket,
  81. SctpSocket,
  82. UnknownSocketType,
  83. };
  84. enum NetworkLayerProtocol
  85. {
  86. IPv4Protocol,
  87. IPv6Protocol,
  88. AnyIPProtocol,
  89. UnknownNetworkLayerProtocol,
  90. };
  91. enum SocketError
  92. {
  93. ConnectionRefusedError,
  94. RemoteHostClosedError,
  95. HostNotFoundError,
  96. SocketAccessError,
  97. SocketResourceError,
  98. SocketTimeoutError,
  99. DatagramTooLargeError,
  100. NetworkError,
  101. AddressInUseError,
  102. SocketAddressNotAvailableError,
  103. UnsupportedSocketOperationError,
  104. UnfinishedSocketOperationError,
  105. ProxyAuthenticationRequiredError,
  106. SslHandshakeFailedError,
  107. ProxyConnectionRefusedError,
  108. ProxyConnectionClosedError,
  109. ProxyConnectionTimeoutError,
  110. ProxyNotFoundError,
  111. ProxyProtocolError,
  112. OperationError,
  113. SslInternalError,
  114. SslInvalidUserDataError,
  115. TemporaryError,
  116. UnknownSocketError,
  117. };
  118. enum SocketState
  119. {
  120. UnconnectedState,
  121. HostLookupState,
  122. ConnectingState,
  123. ConnectedState,
  124. BoundState,
  125. ListeningState,
  126. ClosingState,
  127. };
  128. QAbstractSocket(QAbstractSocket::SocketType socketType, QObject *parent /TransferThis/);
  129. virtual ~QAbstractSocket();
  130. virtual void connectToHost(const QString &hostName, quint16 port, QIODeviceBase::OpenMode mode = QIODeviceBase::ReadWrite, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::AnyIPProtocol) /ReleaseGIL/;
  131. void connectToHost(const QHostAddress &address, quint16 port, QIODeviceBase::OpenMode mode = QIODeviceBase::ReadWrite) /ReleaseGIL/;
  132. virtual void disconnectFromHost() /ReleaseGIL/;
  133. bool isValid() const;
  134. virtual qint64 bytesAvailable() const;
  135. virtual qint64 bytesToWrite() const;
  136. quint16 localPort() const;
  137. QHostAddress localAddress() const;
  138. quint16 peerPort() const;
  139. QHostAddress peerAddress() const;
  140. QString peerName() const;
  141. qint64 readBufferSize() const;
  142. virtual void setReadBufferSize(qint64 size);
  143. void abort();
  144. virtual bool setSocketDescriptor(qintptr socketDescriptor, QAbstractSocket::SocketState state = QAbstractSocket::ConnectedState, QIODeviceBase::OpenMode mode = QIODeviceBase::ReadWrite);
  145. virtual qintptr socketDescriptor() const;
  146. QAbstractSocket::SocketType socketType() const;
  147. QAbstractSocket::SocketState state() const;
  148. QAbstractSocket::SocketError error() const;
  149. virtual void close();
  150. virtual bool isSequential() const;
  151. bool flush() /ReleaseGIL/;
  152. virtual bool waitForConnected(int msecs = 30000) /ReleaseGIL/;
  153. virtual bool waitForReadyRead(int msecs = 30000) /ReleaseGIL/;
  154. virtual bool waitForBytesWritten(int msecs = 30000) /ReleaseGIL/;
  155. virtual bool waitForDisconnected(int msecs = 30000) /ReleaseGIL/;
  156. void setProxy(const QNetworkProxy &networkProxy);
  157. QNetworkProxy proxy() const;
  158. signals:
  159. void hostFound();
  160. void connected();
  161. void disconnected();
  162. void stateChanged(QAbstractSocket::SocketState);
  163. void errorOccurred(QAbstractSocket::SocketError);
  164. void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator);
  165. protected:
  166. virtual SIP_PYOBJECT readData(qint64 maxlen) /TypeHint="bytes",ReleaseGIL/ [qint64 (char *data, qint64 maxlen)];
  167. %MethodCode
  168. // Return the data read or None if there was an error.
  169. if (a0 < 0)
  170. {
  171. PyErr_SetString(PyExc_ValueError, "maximum length of data to be read cannot be negative");
  172. sipIsErr = 1;
  173. }
  174. else
  175. {
  176. char *s = new char[a0];
  177. qint64 len;
  178. Py_BEGIN_ALLOW_THREADS
  179. #if defined(SIP_PROTECTED_IS_PUBLIC)
  180. len = sipSelfWasArg ? sipCpp->QAbstractSocket::readData(s, a0) : sipCpp->readData(s, a0);
  181. #else
  182. len = sipCpp->sipProtectVirt_readData(sipSelfWasArg, s, a0);
  183. #endif
  184. Py_END_ALLOW_THREADS
  185. if (len < 0)
  186. {
  187. Py_INCREF(Py_None);
  188. sipRes = Py_None;
  189. }
  190. else
  191. {
  192. sipRes = PyBytes_FromStringAndSize(s, len);
  193. if (!sipRes)
  194. sipIsErr = 1;
  195. }
  196. delete[] s;
  197. }
  198. %End
  199. virtual SIP_PYOBJECT readLineData(qint64 maxlen) /TypeHint="bytes",ReleaseGIL/ [qint64 (char *data, qint64 maxlen)];
  200. %MethodCode
  201. // Return the data read or None if there was an error.
  202. if (a0 < 0)
  203. {
  204. PyErr_SetString(PyExc_ValueError, "maximum length of data to be read cannot be negative");
  205. sipIsErr = 1;
  206. }
  207. else
  208. {
  209. char *s = new char[a0];
  210. qint64 len;
  211. Py_BEGIN_ALLOW_THREADS
  212. #if defined(SIP_PROTECTED_IS_PUBLIC)
  213. len = sipSelfWasArg ? sipCpp->QAbstractSocket::readLineData(s, a0) : sipCpp->readLineData(s, a0);
  214. #else
  215. len = sipCpp->sipProtectVirt_readLineData(sipSelfWasArg, s, a0);
  216. #endif
  217. Py_END_ALLOW_THREADS
  218. if (len < 0)
  219. {
  220. Py_INCREF(Py_None);
  221. sipRes = Py_None;
  222. }
  223. else
  224. {
  225. sipRes = PyBytes_FromStringAndSize(s, len);
  226. if (!sipRes)
  227. sipIsErr = 1;
  228. }
  229. delete[] s;
  230. }
  231. %End
  232. virtual qint64 writeData(SIP_PYBUFFER) /ReleaseGIL/ [qint64 (const char *data, qint64 len)];
  233. %MethodCode
  234. sipBufferInfoDef bi;
  235. if (sipGetBufferInfo(a0, &bi) > 0)
  236. {
  237. Py_BEGIN_ALLOW_THREADS
  238. #if defined(SIP_PROTECTED_IS_PUBLIC)
  239. sipRes = sipSelfWasArg ?
  240. sipCpp->QAbstractSocket::writeData(reinterpret_cast<char *>(bi.bi_buf), bi.bi_len) :
  241. sipCpp->writeData(reinterpret_cast<char *>(bi.bi_buf), bi.bi_len);
  242. #else
  243. sipRes = sipCpp->sipProtectVirt_writeData(sipSelfWasArg, reinterpret_cast<char *>(bi.bi_buf),
  244. bi.bi_len);
  245. #endif
  246. Py_END_ALLOW_THREADS
  247. sipReleaseBufferInfo(&bi);
  248. }
  249. else
  250. {
  251. sipIsErr = 1;
  252. }
  253. %End
  254. virtual qint64 skipData(qint64 maxSize) /ReleaseGIL/;
  255. void setSocketState(QAbstractSocket::SocketState state);
  256. void setSocketError(QAbstractSocket::SocketError socketError);
  257. void setLocalPort(quint16 port);
  258. void setLocalAddress(const QHostAddress &address);
  259. void setPeerPort(quint16 port);
  260. void setPeerAddress(const QHostAddress &address);
  261. void setPeerName(const QString &name);
  262. public:
  263. enum SocketOption
  264. {
  265. LowDelayOption,
  266. KeepAliveOption,
  267. MulticastTtlOption,
  268. MulticastLoopbackOption,
  269. TypeOfServiceOption,
  270. SendBufferSizeSocketOption,
  271. ReceiveBufferSizeSocketOption,
  272. PathMtuSocketOption,
  273. %If (Qt_6_11_0 -)
  274. KeepAliveIdleOption,
  275. %End
  276. %If (Qt_6_11_0 -)
  277. KeepAliveIntervalOption,
  278. %End
  279. %If (Qt_6_11_0 -)
  280. KeepAliveCountOption,
  281. %End
  282. };
  283. virtual void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value);
  284. virtual QVariant socketOption(QAbstractSocket::SocketOption option);
  285. enum BindFlag /BaseType=Flag/
  286. {
  287. DefaultForPlatform,
  288. ShareAddress,
  289. DontShareAddress,
  290. ReuseAddressHint,
  291. };
  292. typedef QFlags<QAbstractSocket::BindFlag> BindMode;
  293. enum PauseMode /BaseType=Flag/
  294. {
  295. PauseNever,
  296. PauseOnSslErrors,
  297. };
  298. typedef QFlags<QAbstractSocket::PauseMode> PauseModes;
  299. virtual void resume() /ReleaseGIL/;
  300. QAbstractSocket::PauseModes pauseMode() const;
  301. void setPauseMode(QAbstractSocket::PauseModes pauseMode);
  302. virtual bool bind(const QHostAddress &address, quint16 port = 0, QAbstractSocket::BindMode mode = QAbstractSocket::DefaultForPlatform);
  303. bool bind(quint16 port = 0, QAbstractSocket::BindMode mode = QAbstractSocket::DefaultForPlatform);
  304. QString protocolTag() const;
  305. void setProtocolTag(const QString &tag);
  306. };