qudpsocket.sip 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // qudpsocket.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 QUdpSocket : public QAbstractSocket
  22. {
  23. %TypeHeaderCode
  24. #include <qudpsocket.h>
  25. %End
  26. public:
  27. explicit QUdpSocket(QObject *parent /TransferThis/ = 0);
  28. virtual ~QUdpSocket();
  29. bool hasPendingDatagrams() const;
  30. qint64 pendingDatagramSize() const;
  31. SIP_PYOBJECT readDatagram(qint64 maxlen, QHostAddress *host /Out/ = 0, quint16 *port = 0) /TypeHint="bytes",ReleaseGIL/;
  32. %MethodCode
  33. // Return the data read or None if there was an error.
  34. if (a0 < 0)
  35. {
  36. PyErr_SetString(PyExc_ValueError, "maximum length of data to be read cannot be negative");
  37. sipIsErr = 1;
  38. }
  39. else
  40. {
  41. char *s = new char[a0];
  42. qint64 len;
  43. Py_BEGIN_ALLOW_THREADS
  44. len = sipCpp->readDatagram(s, a0, a1, &a2);
  45. Py_END_ALLOW_THREADS
  46. if (len < 0)
  47. {
  48. Py_INCREF(Py_None);
  49. sipRes = Py_None;
  50. }
  51. else
  52. {
  53. sipRes = PyBytes_FromStringAndSize(s, len);
  54. if (!sipRes)
  55. sipIsErr = 1;
  56. }
  57. delete[] s;
  58. }
  59. %End
  60. QNetworkDatagram receiveDatagram(qint64 maxSize = -1) /ReleaseGIL/;
  61. qint64 writeDatagram(SIP_PYBUFFER, const QHostAddress &, quint16) /ReleaseGIL/;
  62. %MethodCode
  63. sipBufferInfoDef bi;
  64. if (sipGetBufferInfo(a0, &bi) > 0)
  65. {
  66. Py_BEGIN_ALLOW_THREADS
  67. sipRes = sipCpp->writeDatagram(reinterpret_cast<char *>(bi.bi_buf),
  68. bi.bi_len, *a1, a2);
  69. Py_END_ALLOW_THREADS
  70. sipReleaseBufferInfo(&bi);
  71. }
  72. else
  73. {
  74. sipIsErr = 1;
  75. }
  76. %End
  77. qint64 writeDatagram(const QNetworkDatagram &datagram) /ReleaseGIL/;
  78. bool joinMulticastGroup(const QHostAddress &groupAddress);
  79. bool joinMulticastGroup(const QHostAddress &groupAddress, const QNetworkInterface &iface);
  80. bool leaveMulticastGroup(const QHostAddress &groupAddress);
  81. bool leaveMulticastGroup(const QHostAddress &groupAddress, const QNetworkInterface &iface);
  82. QNetworkInterface multicastInterface() const;
  83. void setMulticastInterface(const QNetworkInterface &iface);
  84. };