Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

StreamPeerTCP

Inherits: StreamPeer < RefCounted < Object

A stream peer that handles TCP connections.

Description

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.

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.

Methods

Error

bind ( int port, String host="*" )

Error

connect_to_host ( String host, int port )

void

disconnect_from_host ( )

String

get_connected_host ( ) const

int

get_connected_port ( ) const

int

get_local_port ( ) const

Status

get_status ( ) const

Error

poll ( )

void

set_no_delay ( bool enabled )


Enumerations

enum Status:

Status STATUS_NONE = 0

The initial status of the StreamPeerTCP. This is also the status after disconnecting.

Status STATUS_CONNECTING = 1

A status representing a StreamPeerTCP that is connecting to a host.

Status STATUS_CONNECTED = 2

A status representing a StreamPeerTCP that is connected to a host.