• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

TCP data?

Neptune

Member
Say I'm wanting to send 20 pieces of data (ints, floats, strings etc) over a TCP type connection, is it reasonable to pack all of the data into a list, write the list to a string, and then send one buffer containing the string over the network? Is this pretty standard?

I'm new to networking and any information is appreciated :)
 

rytan451

Member
If it works, it's reasonable. It isn't ideal, by any means: you'd usually want both ends of the connection to be in agreement on what sort of data is being sent (and in what order), and send the data directly as a buffer. Even so, "reasonable and working" is always better than "theoretically ideal, but practically not working yet".
 

Neptune

Member
Thanks for reply.
On the client side, I'm not too concerned. Though likely unconventional, I'm meticulous and effective.

But for actually sending data over a network, I don't know what I'm doing -- is sending a written string in one buffer really bad, compared to sending the individual types in a few different buffers?
 

chamaeleon

Member
First, the string serialization of ds data structures is not very efficient. Second, personally I'd stay away from using a serialization protocol that is more or less a black box and does not really have readily available implementations for non-GMS programs. Unless you plan to throw it away, I'd recommend nailing down what you want to transmit, come up with a schema for your data that you control fully and are able to implement in whatever software you may need to, optionally with means for you to extend it over time as new features becomes requirements. Having networking functionality working at all with all that it entails, keeping state consistent among programs communication with each other, the serialization process should be a fairly minor detail in comparison.
 

Neptune

Member
Alright thanks for the input.
For now, attempting to send the data in one chunk is how I'll do it, only because it is strange and new and ambiguous using buffers, at least until I get the hang of them.

I'll try to post some code tomorrow, because I think I may be doing something wrong.
 

Neptune

Member
@chamaeleon I appreciate any help you can offer me.
I'm having a problem that the user who is flagged as the HOST (global.server_host == true) is not getting the client's data back, but is sending their own data just fine to the other client.

Here is what my "async network" event looks like.
The MULTI_DATA.player is basically just the general information about a player object - appearance, x/y, state etc
1602354741945.png

This is sending the data to the clients (if the user is the authoritative host) - Step Event
1602355055633.png

This is the clients receiving data - Step Event
1602355191370.png
 

chamaeleon

Member
If I were you I'd implement some kind of logging functionality so you can get traces of network communication along with pertinent pieces of data (json_encode(async_load) is useful to me at the beginning of network events when I'm unsure about what is going on, along with output displaying what case is handled in switch statements, etc.) In particular, I'd pay attention to the id and socket values in that structure, and ensure the right value is used when sending data using network_send_packet().
 
Top