0 votes

I'm having trouble setting up an asynchronous TCP connection with a server I created; what I'm currently doing is:

  1. Creating a new StreamPeerTCP object on my script.
  2. Use streamtcp.connect_to_host(server_ip, server_port)

The server-side looks correct (a new tcp client shows up), but on Godot I can't seem to find any way to set signals for successful StreamPeer connections nor signals for receiving packets - I'm currently having to rely on _process to check when the connection state of the StreamPeerTCP ever changed, and the SceneTree signals networkd_peer_connected and connected_to_server doesn't seem to trigger ever. Is this a bug?

in Engine by (298 points)
edited by

Actually network_peer_connected and connected_to_server are signals from the high level API. When you use StreamTCP.connect_to_host() it returns an error code that is OK or FAILURE. You can get the status of the connection with the method StreamTCP.get_status() that returns the status of connection. See https://docs.godotengine.org/en/3.1/classes/class_streampeertcp.html

So, it is not a bug, you just dont use signals with this API.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.