TCPServer.xml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="TCPServer" inherits="RefCounted" version="4.0">
  3. <brief_description>
  4. A TCP server.
  5. </brief_description>
  6. <description>
  7. A TCP server. Listens to connections on a port and returns a [StreamPeerTCP] when it gets an incoming connection.
  8. [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] 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.
  9. </description>
  10. <tutorials>
  11. </tutorials>
  12. <methods>
  13. <method name="get_local_port" qualifiers="const">
  14. <return type="int" />
  15. <description>
  16. Returns the local port this server is listening to.
  17. </description>
  18. </method>
  19. <method name="is_connection_available" qualifiers="const">
  20. <return type="bool" />
  21. <description>
  22. Returns [code]true[/code] if a connection is available for taking.
  23. </description>
  24. </method>
  25. <method name="is_listening" qualifiers="const">
  26. <return type="bool" />
  27. <description>
  28. Returns [code]true[/code] if the server is currently listening for connections.
  29. </description>
  30. </method>
  31. <method name="listen">
  32. <return type="int" enum="Error" />
  33. <argument index="0" name="port" type="int" />
  34. <argument index="1" name="bind_address" type="String" default="&quot;*&quot;" />
  35. <description>
  36. Listen on the [code]port[/code] binding to [code]bind_address[/code].
  37. If [code]bind_address[/code] is set as [code]"*"[/code] (default), the server will listen on all available addresses (both IPv4 and IPv6).
  38. If [code]bind_address[/code] is set as [code]"0.0.0.0"[/code] (for IPv4) or [code]"::"[/code] (for IPv6), the server will listen on all available addresses matching that IP type.
  39. If [code]bind_address[/code] is set to any valid address (e.g. [code]"192.168.1.101"[/code], [code]"::1"[/code], etc), the server will only listen on the interface with that addresses (or fail if no interface with the given address exists).
  40. </description>
  41. </method>
  42. <method name="stop">
  43. <return type="void" />
  44. <description>
  45. Stops listening.
  46. </description>
  47. </method>
  48. <method name="take_connection">
  49. <return type="StreamPeerTCP" />
  50. <description>
  51. If a connection is available, returns a StreamPeerTCP with the connection.
  52. </description>
  53. </method>
  54. </methods>
  55. </class>