2017-09-12 20:42:36 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2020-02-01 01:03:48 +00:00
<class name= "TCP_Server" inherits= "Reference" version= "4.0" >
2017-09-12 20:42:36 +00:00
<brief_description >
2019-06-21 23:04:47 +00:00
A TCP server.
2017-09-12 20:42:36 +00:00
</brief_description>
<description >
2019-06-21 23:04:47 +00:00
A TCP server. Listens to connections on a port and returns a [StreamPeerTCP] when it gets an incoming connection.
2017-09-12 20:42:36 +00:00
</description>
<tutorials >
</tutorials>
<methods >
2021-03-21 10:15:30 +00:00
<method name= "get_local_port" qualifiers= "const" >
<return type= "int" >
</return>
<description >
Returns the local port this server is listening to.
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "is_connection_available" qualifiers= "const" >
<return type= "bool" >
</return>
<description >
2019-05-24 02:15:43 +00:00
Returns [code]true[/code] if a connection is available for taking.
2017-09-12 20:42:36 +00:00
</description>
</method>
2019-06-30 17:28:13 +00:00
<method name= "is_listening" qualifiers= "const" >
<return type= "bool" >
</return>
<description >
Returns [code]true[/code] if the server is currently listening for connections.
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "listen" >
<return type= "int" enum= "Error" >
</return>
<argument index= "0" name= "port" type= "int" >
</argument>
<argument index= "1" name= "bind_address" type= "String" default= ""*"" >
</argument>
<description >
2019-06-21 23:04:47 +00:00
Listen on the [code]port[/code] binding to [code]bind_address[/code].
If [code]bind_address[/code] is set as [code]"*"[/code] (default), the server will listen on all available addresses (both IPv4 and IPv6).
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.
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).
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "stop" >
<return type= "void" >
</return>
<description >
2019-06-21 23:04:47 +00:00
Stops listening.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "take_connection" >
<return type= "StreamPeerTCP" >
</return>
<description >
2019-06-21 23:04:47 +00:00
If a connection is available, returns a StreamPeerTCP with the connection.
2017-09-12 20:42:36 +00:00
</description>
</method>
</methods>
<constants >
</constants>
</class>