Can anyone help me with sending tcp packets to a server written in luasocket?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By kicknbrit

Hello, I am new to this engine and I am trying to move a server based love2d game to godot.

The problem is when I try to send tcp packets to the luasocket server from godot the server gets some weird symbol instead of text.

When I set it so that the luasocket server only matches alpha-numeric text, the server doesn’t receive anything at all.

I recall reading something about Godot sending a certain amount of bytes for the size of the packet to its destination, but I don’t really understand any of this because with lua socket I can just send text and it will arrive at its destination.

This is the luasocket server code that receives data from any connected tcp clients:

	for k, v in pairs(Component.Networking.ClientList) do 
        local Data = v.TcpClientObject:receive()
        if Data ~= nil then
         	Data = Data:gsub('%W','') 

And this is the Gdscript code I am using to send the tcp data to the server in Godot:
var CreateAccountRequest = "CRTAC James\n" PeerStream = PeerStream.set_stream_peer(TcpConnection) PeerStream.put_var(CreateAccountRequest ) TcpConnection.put_utf8_string(CreateAccountRequest )

Can anyone help me sort this out?
Thanks :slight_smile:

:bust_in_silhouette: Reply From: kicknbrit

I figured it out!

Or at least I figured out a solution.

var hiserver = "CRTAC James\n"
var AsciiString = hiserver.to_ascii()
var TempByteArray = PoolByteArray(AsciiString)