Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | wombatTurkey | |
Old Version | Published before Godot 3 was released. |
Example to connect:
func connectToServer(ip, port):
client = StreamPeerTCP.new()
client.connect(ip, port)
Then in my update
, I use: (this might be where my problem is)
if client.is_connected() && client.get_available_bytes() >0:
print(str(client.get_string(client.get_available_bytes())))
Now, I’m running a basic TCP Server in nodejs
. If I do:
socket.write('PATCH 1.10')
socket.write('PATCH 1.10')
socket.write('PATCH 1.10')
socket.write('PATCH 1.10')
socket.write('PATCH 1.10')
socket.write('PATCH 1.10')
socket.write('PATCH 1.10')
socket.write('PATCH 1.10')
It actually doesn’t send as individual messages, so when I get my string from get_string
(above) I receive:
Is there a way to make it so each time a message (packet) is sent, they come as individual packets instead of added to the TCP Stream? Thanks for reading!
Sorry folks, looks like this is just how TCP Works (Stream Based)
java - NodeJS TCP Server, onData small chunks - Stack Overflow
I don’t think it’s Godot’s fault. I’m just used to my WebSocket server
More info here: networking - TCP stream vs UDP message - Stack Overflow
wombatTurkey | 2016-07-28 02:38
This might be related: https://forum.godotengine.org/5298/tcp-networking-messages-arriving-clumps-missing-something?show=5298#q5298
ericdl | 2016-07-28 17:40