Skip to content
0.2.0-dev Download ZIP
57 lines ·2.8 KB Raw
1<?xml version="1.0" encoding="UTF-8" ?>
2<class name="StreamPeerTCP" inherits="StreamPeerSocket" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 A stream peer that handles TCP connections.
5 </brief_description>
6 <description>
7 A stream peer that handles TCP connections. This object can be used to connect to TCP servers, or also is returned by a TCP server.
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 remote deploy. Otherwise, network communication of any kind will be blocked by Android.
9 </description>
10 <tutorials>
11 </tutorials>
12 <methods>
13 <method name="bind">
14 <return type="int" enum="Error" />
15 <param index="0" name="port" type="int" />
16 <param index="1" name="host" type="String" default="&quot;*&quot;" />
17 <description>
18 Opens the TCP socket, and binds it to the specified local address.
19 This method is generally not needed, and only used to force the subsequent call to [method connect_to_host] to use the specified [param host] and [param port] as source address. This can be desired in some NAT punchthrough techniques, or when forcing the source network interface.
20 </description>
21 </method>
22 <method name="connect_to_host">
23 <return type="int" enum="Error" />
24 <param index="0" name="host" type="String" />
25 <param index="1" name="port" type="int" />
26 <description>
27 Connects to the specified [code]host:port[/code] pair. A hostname will be resolved if valid. Returns [constant OK] on success.
28 </description>
29 </method>
30 <method name="get_connected_host" qualifiers="const">
31 <return type="String" />
32 <description>
33 Returns the IP of this peer.
34 </description>
35 </method>
36 <method name="get_connected_port" qualifiers="const">
37 <return type="int" />
38 <description>
39 Returns the port of this peer.
40 </description>
41 </method>
42 <method name="get_local_port" qualifiers="const">
43 <return type="int" />
44 <description>
45 Returns the local port to which this peer is bound.
46 </description>
47 </method>
48 <method name="set_no_delay">
49 <return type="void" />
50 <param index="0" name="enabled" type="bool" />
51 <description>
52 If [param enabled] is [code]true[/code], packets will be sent immediately. If [param enabled] is [code]false[/code] (the default), packet transfers will be delayed and combined using [url=https://en.wikipedia.org/wiki/Nagle%27s_algorithm]Nagle's algorithm[/url].
53 [b]Note:[/b] It's recommended to leave this disabled for applications that send large packets or need to transfer a lot of data, as enabling this can decrease the total available bandwidth.
54 </description>
55 </method>
56 </methods>
57</class>