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.
Checking the stable version of the documentation...
TCPServer
繼承: SocketServer < RefCounted < Object
TCP 伺服器。
說明
TCP 伺服器。監聽埠上的連接,並在獲得傳入連接時返回 StreamPeerTCP。
注意:匯出到安卓時,在匯出專案或使用一鍵部署之前,請務必在安卓匯出預設中開啟 INTERNET 許可權。否則 Android 會阻止任何形式的網路通信。
方法
get_local_port() const |
|
方法說明
返回該伺服器正在監聽的本地埠。
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() 🔗
如果連接可用,則返回帶有該連接的 StreamPeerTCP。