class_tcpserver.rst 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/TCPServer.xml.
  6. .. _class_TCPServer:
  7. TCPServer
  8. =========
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. A TCP server.
  11. Description
  12. -----------
  13. A TCP server. Listens to connections on a port and returns a :ref:`StreamPeerTCP<class_StreamPeerTCP>` when it gets an incoming connection.
  14. \ **Note:** When exporting to Android, make sure to enable the ``INTERNET`` permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
  15. Methods
  16. -------
  17. +-------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`int<class_int>` | :ref:`get_local_port<class_TCPServer_method_get_local_port>` **(** **)** |const| |
  19. +-------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`bool<class_bool>` | :ref:`is_connection_available<class_TCPServer_method_is_connection_available>` **(** **)** |const| |
  21. +-------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`bool<class_bool>` | :ref:`is_listening<class_TCPServer_method_is_listening>` **(** **)** |const| |
  23. +-------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`listen<class_TCPServer_method_listen>` **(** :ref:`int<class_int>` port, :ref:`String<class_String>` bind_address="*" **)** |
  25. +-------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`stop<class_TCPServer_method_stop>` **(** **)** |
  27. +-------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`StreamPeerTCP<class_StreamPeerTCP>` | :ref:`take_connection<class_TCPServer_method_take_connection>` **(** **)** |
  29. +-------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  30. Method Descriptions
  31. -------------------
  32. .. _class_TCPServer_method_get_local_port:
  33. - :ref:`int<class_int>` **get_local_port** **(** **)** |const|
  34. Returns the local port this server is listening to.
  35. ----
  36. .. _class_TCPServer_method_is_connection_available:
  37. - :ref:`bool<class_bool>` **is_connection_available** **(** **)** |const|
  38. Returns ``true`` if a connection is available for taking.
  39. ----
  40. .. _class_TCPServer_method_is_listening:
  41. - :ref:`bool<class_bool>` **is_listening** **(** **)** |const|
  42. Returns ``true`` if the server is currently listening for connections.
  43. ----
  44. .. _class_TCPServer_method_listen:
  45. - :ref:`Error<enum_@GlobalScope_Error>` **listen** **(** :ref:`int<class_int>` port, :ref:`String<class_String>` bind_address="*" **)**
  46. Listen on the ``port`` binding to ``bind_address``.
  47. If ``bind_address`` is set as ``"*"`` (default), the server will listen on all available addresses (both IPv4 and IPv6).
  48. 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.
  49. 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).
  50. ----
  51. .. _class_TCPServer_method_stop:
  52. - void **stop** **(** **)**
  53. Stops listening.
  54. ----
  55. .. _class_TCPServer_method_take_connection:
  56. - :ref:`StreamPeerTCP<class_StreamPeerTCP>` **take_connection** **(** **)**
  57. If a connection is available, returns a StreamPeerTCP with the connection.
  58. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  59. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  60. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  61. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  62. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  63. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`