godotengine / godotengine/godot-docs

Add an example of continuously listening to a TCP stream in StreamPeerTCP

Open
#4,437 0 comments 0 reactions 0 assignees View on GitHub
area:class reference enhancement
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

**Your Godot version:** 3.2.3

**Issue description:**

We should add an example of continuously listening to a TCP stream in the StreamPeerTCP class reference.

> For the stream itself, I am very indebted to [this little project](https://github.com/stisa/godot-tcp-example/tree/master/godot_tcp), as it showed me that you can use the process function in Godot to periodically listen to the TCP stream, which was a connection I hadn’t been able to make from the documentation. After I got that done, I still had some trouble getting the server to accept my data… turns out Godot’s convenience functions for strings and others helpfully prefixes it with a few bytes to indicate the size of the sent data. Using `put_data(string.to_utf8())` for this solved everything. Now the server was accepting my stream!
> […]
> The example of the TCP stream above would make a really good sample for the StreamPeer pages, like, giving users the idea they could use the process function to listen for incoming messages.

See https://wolthera.info/2020/12/xmpp-client-in-godot/.

**URL to the documentation page (if already existing):** https://docs.godotengine.org/en/latest/classes/class_streampeertcp.html

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.