Godot Version
v4.3.stable.official [77dcf97d8]
Question
I tried to connect to a server using the following code:
extends Node
var irc: StreamPeerTCP = StreamPeerTCP.new()
var thread: Thread
func _ready():
thread = Thread.new()
thread.start(connect_to_server.bind("irc.libera.chat", "#bottesting", "SparkwavesTestClient"))
func connect_to_server(server: String, channel: String, nickname: String):
print("Connecting to " + server + ":6667")
irc.connect_to_host(server, 6667)
while irc.get_status() == StreamPeerTCP.STATUS_CONNECTING:
pass
print("You will never see this")
The console never prints the last print line, and .get_status()
is permanently stuck on StreamPeerTCP.STATUS_CONNECTING
. If I do not put it in a thread the entire application freezes instead. I tried connecting using ncat instead, and it connected instantly. It does this no matter what kind of URL I connect to as long as it’s a valid URL, even localhost. An invalid URL exits correctly.