summaryrefslogtreecommitdiff
path: root/doc/classes/TCPServer.xml
blob: 7160055c6d13f8cffa492ebb34a9ffb21bdca300 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?xml version="1.0" encoding="UTF-8" ?>
<class name="TCPServer" inherits="RefCounted" version="4.0">
	<brief_description>
		A TCP server.
	</brief_description>
	<description>
		A TCP server. Listens to connections on a port and returns a [StreamPeerTCP] when it gets an incoming connection.
	</description>
	<tutorials>
	</tutorials>
	<methods>
		<method name="get_local_port" qualifiers="const">
			<return type="int">
			</return>
			<description>
				Returns the local port this server is listening to.
			</description>
		</method>
		<method name="is_connection_available" qualifiers="const">
			<return type="bool">
			</return>
			<description>
				Returns [code]true[/code] if a connection is available for taking.
			</description>
		</method>
		<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>
		<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="&quot;*&quot;">
			</argument>
			<description>
				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).
			</description>
		</method>
		<method name="stop">
			<return type="void">
			</return>
			<description>
				Stops listening.
			</description>
		</method>
		<method name="take_connection">
			<return type="StreamPeerTCP">
			</return>
			<description>
				If a connection is available, returns a StreamPeerTCP with the connection.
			</description>
		</method>
	</methods>
	<constants>
	</constants>
</class>