Hello,
is there any 4.2+ TCP Server example?
for example UDP have like here:
while TCP do not have examples like here:
and googling examples i only seems some Client(but not Server) examples or unsafe-download examples.
need to send messages from different (no-godot) app into godot TCP Server.
got something working, but problem is:
using use peerTCP.get_data(bytes) and peerTCP.get_available_bytes()
while more than one messages can be contained in get_data(bytes)
Thought to send message length in bytes first, but i guess i do something totally wrong.
Because didnt seen proper examples.
But i belive there is better build in solution for TCP?
For example current solution can receive:
[28, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 28, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 10, 0, 0, 0, 28, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 8, 0, 0, 0, 115, 111, 117, 110, 100, 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 8, 0, 0, 0, 115, 99, 101, 110, 101, 0, 0, 0, 28, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 12, 0, 0, 0, 99, 104, 97, 114, 97, 99, 116, 101, 114, 0, 0, 0, 4, 0, 0, 0, 44, 0, 0, 0, 97, 115, 115, 101, 116, 115, 47, 115, 99, 101, 110, 101, 115, 47, 99, 104, 97, 114, 97, 99, 116, 101, 114, 47, 99, 104, 97, 114, 97, 99, 116, 101, 114, 46, 115, 99, 101, 110, 101, 46, 116, 115, 99, 110, 4, 0, 0, 0, 8, 0, 0, 0, 116, 101, 114, 114, 97, 105, 110, 0, 4, 0, 0, 0, 52, 0, 0, 0, 97, 100, 100, 111, 110, 115, 47, 114, 97, 100, 105, 97, 110, 99, 101, 45, 116, 101, 114, 114, 97, 105, 110, 47, 116, 101, 114, 114, 97, 105, 110, 47, 116, 101, 114, 114, 97, 105, 110, 46, 115, 99, 101, 110, 101, 46, 116, 115, 99, 110, 0, 0, 28, 0, 0, 0, 3, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 2, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 28, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 20, 0, 0, 0, 76, 111, 99, 97, 116, 105, 111, 110, 67, 111, 109, 112, 111, 110, 101, 110, 116, 0, 0, 0, 28, 0, 0, 0, 2, 0, 0, 0, 4, 0, 0, 0, 8, 0, 0, 0, 112, 111, 115, 105, 116, 105, 111, 110, 28, 0, 0, 0, 3, 0, 0, 0, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 16, 0, 0, 0, 83, 99, 101, 110, 101, 67, 111, 109, 112, 111, 110, 101, 110, 116, 0, 0, 28, 0, 0, 0, 2, 0, 0, 0, 4, 0, 0, 0, 8, 0, 0, 0, 115, 99, 101, 110, 101, 0, 0, 0, 4, 0, 0, 0, 8, 0, 0, 0, 116, 101, 114, 114, 97, 105, 110, 0]
that give me [0, 0] after var value = bytes_to_var(available_bytes);
(that is only first array(28 code) but not second - could also use this to split message into 2 messages, but again im not sure if this is a way to go)
while it contains more data (second message) there
UDP works fine tho. But with UDP also needed to create more channels, since Godot was loosing a lot of packages when did stress-test of messages locally(127.0.0.1)
Btw, seen one code that use:
peerstream = PacketPeerStream.new()
peerstream.set_stream_peer( connection )
but it didnt work for me at all since peerstream.get_available_packet_count() was always 0 for me. (even when there was data from client)