What I get is that the socket (I'll always refer to StreamPeerTCP instances as "socket" in this question) starts in STATUS_NONE. Then when you establish a connection it will go through STATUS_CONNECTING and STATUS_CONNECTED. Then, on closed, it will go back to STATUS_NONE again.
But there is another status which is STATUS_ERROR. I have several questions out of it:
- What are all the scenarios (actually: scenario types) where a socket can go into STATUS_ERROR status?
- Is that a recoverable or an unrecoverable status? What should I understand when reaching the STATUS_ERROR status? Should I close the connection from my side and start over again? Or are there scenarios where I can keep my connection and keep it open / not consider it closed / terminated / ... even when on STATUS_ERROR?
I'm asking because I found some scenarios when I had an async loop that waited until a socket.poll(), then I found that the status was STATUS_ERROR suddenly (and I was working my look by always requiring the current status to be STATUS_CONNECTED actually).
Wairing for the .poll was done using Godot 4's await keyword (i.e. await self.custom_signal) considering a _process like this:
func _process(d):
socket.poll()
emit_signal("custom_signal")