class_streampeertcp.rst 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/StreamPeerTCP.xml.
  6. .. _class_StreamPeerTCP:
  7. StreamPeerTCP
  8. =============
  9. **Inherits:** :ref:`StreamPeer<class_StreamPeer>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  10. TCP stream peer.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. TCP stream peer. This object can be used to connect to TCP servers, or also is returned by a TCP server.
  15. .. rst-class:: classref-reftable-group
  16. Methods
  17. -------
  18. .. table::
  19. :widths: auto
  20. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`connect_to_host<class_StreamPeerTCP_method_connect_to_host>` **(** :ref:`String<class_String>` host, :ref:`int<class_int>` port **)** |
  22. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`disconnect_from_host<class_StreamPeerTCP_method_disconnect_from_host>` **(** **)** |
  24. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`String<class_String>` | :ref:`get_connected_host<class_StreamPeerTCP_method_get_connected_host>` **(** **)** |const| |
  26. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`int<class_int>` | :ref:`get_connected_port<class_StreamPeerTCP_method_get_connected_port>` **(** **)** |const| |
  28. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Status<enum_StreamPeerTCP_Status>` | :ref:`get_status<class_StreamPeerTCP_method_get_status>` **(** **)** |
  30. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | :ref:`is_connected_to_host<class_StreamPeerTCP_method_is_connected_to_host>` **(** **)** |const| |
  32. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`set_no_delay<class_StreamPeerTCP_method_set_no_delay>` **(** :ref:`bool<class_bool>` enabled **)** |
  34. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  35. .. rst-class:: classref-section-separator
  36. ----
  37. .. rst-class:: classref-descriptions-group
  38. Enumerations
  39. ------------
  40. .. _enum_StreamPeerTCP_Status:
  41. .. rst-class:: classref-enumeration
  42. enum **Status**:
  43. .. _class_StreamPeerTCP_constant_STATUS_NONE:
  44. .. rst-class:: classref-enumeration-constant
  45. :ref:`Status<enum_StreamPeerTCP_Status>` **STATUS_NONE** = ``0``
  46. The initial status of the **StreamPeerTCP**. This is also the status after disconnecting.
  47. .. _class_StreamPeerTCP_constant_STATUS_CONNECTING:
  48. .. rst-class:: classref-enumeration-constant
  49. :ref:`Status<enum_StreamPeerTCP_Status>` **STATUS_CONNECTING** = ``1``
  50. A status representing a **StreamPeerTCP** that is connecting to a host.
  51. .. _class_StreamPeerTCP_constant_STATUS_CONNECTED:
  52. .. rst-class:: classref-enumeration-constant
  53. :ref:`Status<enum_StreamPeerTCP_Status>` **STATUS_CONNECTED** = ``2``
  54. A status representing a **StreamPeerTCP** that is connected to a host.
  55. .. _class_StreamPeerTCP_constant_STATUS_ERROR:
  56. .. rst-class:: classref-enumeration-constant
  57. :ref:`Status<enum_StreamPeerTCP_Status>` **STATUS_ERROR** = ``3``
  58. A status representing a **StreamPeerTCP** in error state.
  59. .. rst-class:: classref-section-separator
  60. ----
  61. .. rst-class:: classref-descriptions-group
  62. Method Descriptions
  63. -------------------
  64. .. _class_StreamPeerTCP_method_connect_to_host:
  65. .. rst-class:: classref-method
  66. :ref:`Error<enum_@GlobalScope_Error>` **connect_to_host** **(** :ref:`String<class_String>` host, :ref:`int<class_int>` port **)**
  67. Connects to the specified ``host:port`` pair. A hostname will be resolved if valid. Returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success or :ref:`@GlobalScope.FAILED<class_@GlobalScope_constant_FAILED>` on failure.
  68. .. rst-class:: classref-item-separator
  69. ----
  70. .. _class_StreamPeerTCP_method_disconnect_from_host:
  71. .. rst-class:: classref-method
  72. void **disconnect_from_host** **(** **)**
  73. Disconnects from host.
  74. .. rst-class:: classref-item-separator
  75. ----
  76. .. _class_StreamPeerTCP_method_get_connected_host:
  77. .. rst-class:: classref-method
  78. :ref:`String<class_String>` **get_connected_host** **(** **)** |const|
  79. Returns the IP of this peer.
  80. .. rst-class:: classref-item-separator
  81. ----
  82. .. _class_StreamPeerTCP_method_get_connected_port:
  83. .. rst-class:: classref-method
  84. :ref:`int<class_int>` **get_connected_port** **(** **)** |const|
  85. Returns the port of this peer.
  86. .. rst-class:: classref-item-separator
  87. ----
  88. .. _class_StreamPeerTCP_method_get_status:
  89. .. rst-class:: classref-method
  90. :ref:`Status<enum_StreamPeerTCP_Status>` **get_status** **(** **)**
  91. Returns the status of the connection, see :ref:`Status<enum_StreamPeerTCP_Status>`.
  92. .. rst-class:: classref-item-separator
  93. ----
  94. .. _class_StreamPeerTCP_method_is_connected_to_host:
  95. .. rst-class:: classref-method
  96. :ref:`bool<class_bool>` **is_connected_to_host** **(** **)** |const|
  97. Returns ``true`` if this peer is currently connected or is connecting to a host, ``false`` otherwise.
  98. .. rst-class:: classref-item-separator
  99. ----
  100. .. _class_StreamPeerTCP_method_set_no_delay:
  101. .. rst-class:: classref-method
  102. void **set_no_delay** **(** :ref:`bool<class_bool>` enabled **)**
  103. If ``enabled`` is ``true``, packets will be sent immediately. If ``enabled`` is ``false`` (the default), packet transfers will be delayed and combined using `Nagle's algorithm <https://en.wikipedia.org/wiki/Nagle%27s_algorithm>`__.
  104. \ **Note:** It's recommended to leave this disabled for applications that send large packets or need to transfer a lot of data, as enabling this can decrease the total available bandwidth.
  105. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  106. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  107. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  108. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`