TCPServer
Hereda: 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
get_local_port() const |
|
is_connection_available() const |
|
is_listening() const |
|
void |
stop() |
Descripciones de Métodos
Devuelve el puerto local que este servidor está escuchando.
bool is_connection_available() const 🔗
Devuelve true si hay una conexión disponible para tomar.
Devuelve true si el servidor está actualmente a la escucha de las conexiones.
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).
void stop() 🔗
Para de escuchar.
StreamPeerTCP take_connection() 🔗
Si hay una conexión disponible, devuelve un StreamPeerTCP con la conexión.