Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

TCPServer

Hereda: SocketServer < RefCounted < Object

Un servidor TCP.

Descripción

Un servidor TCP. Escucha las conexiones en un puerto y devuelve un StreamPeerTCP cuando recibe una conexión entrante.

Nota: Al exportar a Android, asegúrate de habilitar el permiso INTERNET en el preajuste de exportación de Android antes de exportar el proyecto o usar el despliegue con un solo clic. De lo contrario, cualquier tipo de comunicación de red será bloqueada por Android.

Métodos

int

get_local_port() const

Error

listen(port: int, bind_address: String = "*")

StreamPeerTCP

take_connection()


Descripciones de Métodos

int get_local_port() const 🔗

Devuelve el puerto local que este servidor está escuchando.


Error listen(port: int, bind_address: String = "*") 🔗

Listen on the port binding to bind_address.

If bind_address is set as "*" (default), the server will listen on all available addresses (both IPv4 and IPv6).

If bind_address is set as "0.0.0.0" (for IPv4) or "::" (for IPv6), the server will listen on all available addresses matching that IP type.

If bind_address is set to any valid address (e.g. "192.168.1.101", "::1", etc.), the server will only listen on the interface with that address (or fail if no interface with the given address exists).


StreamPeerTCP take_connection() 🔗

Si hay una conexión disponible, devuelve un StreamPeerTCP con la conexión.