class_tcp_server.rst 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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/TCP_Server.xml.
  6. .. _class_TCP_Server:
  7. TCP_Server
  8. ==========
  9. **Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  10. A TCP server.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. A TCP server. Listens to connections on a port and returns a :ref:`StreamPeerTCP<class_StreamPeerTCP>` when it gets an incoming connection.
  15. .. rst-class:: classref-reftable-group
  16. Methods
  17. -------
  18. .. table::
  19. :widths: auto
  20. +-------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`bool<class_bool>` | :ref:`is_connection_available<class_TCP_Server_method_is_connection_available>` **(** **)** |const| |
  22. +-------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`bool<class_bool>` | :ref:`is_listening<class_TCP_Server_method_is_listening>` **(** **)** |const| |
  24. +-------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`listen<class_TCP_Server_method_listen>` **(** :ref:`int<class_int>` port, :ref:`String<class_String>` bind_address="*" **)** |
  26. +-------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  27. | void | :ref:`stop<class_TCP_Server_method_stop>` **(** **)** |
  28. +-------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`StreamPeerTCP<class_StreamPeerTCP>` | :ref:`take_connection<class_TCP_Server_method_take_connection>` **(** **)** |
  30. +-------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  31. .. rst-class:: classref-section-separator
  32. ----
  33. .. rst-class:: classref-descriptions-group
  34. Method Descriptions
  35. -------------------
  36. .. _class_TCP_Server_method_is_connection_available:
  37. .. rst-class:: classref-method
  38. :ref:`bool<class_bool>` **is_connection_available** **(** **)** |const|
  39. Returns ``true`` if a connection is available for taking.
  40. .. rst-class:: classref-item-separator
  41. ----
  42. .. _class_TCP_Server_method_is_listening:
  43. .. rst-class:: classref-method
  44. :ref:`bool<class_bool>` **is_listening** **(** **)** |const|
  45. Returns ``true`` if the server is currently listening for connections.
  46. .. rst-class:: classref-item-separator
  47. ----
  48. .. _class_TCP_Server_method_listen:
  49. .. rst-class:: classref-method
  50. :ref:`Error<enum_@GlobalScope_Error>` **listen** **(** :ref:`int<class_int>` port, :ref:`String<class_String>` bind_address="*" **)**
  51. Listen on the ``port`` binding to ``bind_address``.
  52. If ``bind_address`` is set as ``"*"`` (default), the server will listen on all available addresses (both IPv4 and IPv6).
  53. If ``bind_address`` is set as ``"0.0.0.0"`` (for IPv4) or ``"::"`` (for IPv6), the server will listen on all available addresses matching that IP type.
  54. If ``bind_address`` is set to any valid address (e.g. ``"192.168.1.101"``, ``"::1"``, etc), the server will only listen on the interface with that addresses (or fail if no interface with the given address exists).
  55. .. rst-class:: classref-item-separator
  56. ----
  57. .. _class_TCP_Server_method_stop:
  58. .. rst-class:: classref-method
  59. void **stop** **(** **)**
  60. Stops listening.
  61. .. rst-class:: classref-item-separator
  62. ----
  63. .. _class_TCP_Server_method_take_connection:
  64. .. rst-class:: classref-method
  65. :ref:`StreamPeerTCP<class_StreamPeerTCP>` **take_connection** **(** **)**
  66. If a connection is available, returns a StreamPeerTCP with the connection.
  67. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  68. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  69. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  70. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`